From 7c8c300d24a360d28eb12b9661a48680a55e49fc Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 30 Sep 2024 11:12:42 +0000 Subject: [PATCH] CodeGen from PR 3515 in test-repo-billy/azure-rest-api-specs Merge e1efab546f25d31c16635236459305ceac48a05f into 02e500856ce974e6873e205ffdb6523ffdc60bb7 --- .../azure-mgmt-apimanagement/_meta.json | 10 +- .../apimanagement/_api_management_client.py | 323 +- .../mgmt/apimanagement/_configuration.py | 6 +- .../azure/mgmt/apimanagement/_patch.py | 1 + .../mgmt/apimanagement/_serialization.py | 4 +- .../azure/mgmt/apimanagement/_vendor.py | 10 - .../azure/mgmt/apimanagement/_version.py | 2 +- .../aio/_api_management_client.py | 329 +- .../mgmt/apimanagement/aio/_configuration.py | 6 +- .../azure/mgmt/apimanagement/aio/_patch.py | 1 + .../azure/mgmt/apimanagement/aio/_vendor.py | 2 - .../apimanagement/aio/operations/__init__.py | 104 +- .../operations/_all_policies_operations.py | 141 + .../operations/_api_diagnostic_operations.py | 45 +- .../aio/operations/_api_export_operations.py | 21 +- ...pi_gateway_config_connection_operations.py | 559 +++ .../aio/operations/_api_gateway_operations.py | 809 ++++ .../_api_issue_attachment_operations.py | 40 +- .../_api_issue_comment_operations.py | 40 +- .../aio/operations/_api_issue_operations.py | 45 +- .../_api_management_client_operations.py | 41 +- ..._api_management_gateway_skus_operations.py | 144 + .../_api_management_operations_operations.py | 16 +- .../_api_management_service_operations.py | 320 +- ..._api_management_service_skus_operations.py | 16 +- .../_api_management_skus_operations.py | 16 +- ...pi_management_workspace_link_operations.py | 116 + ...i_management_workspace_links_operations.py | 142 + .../operations/_api_operation_operations.py | 45 +- .../_api_operation_policy_operations.py | 41 +- .../aio/operations/_api_operations.py | 198 +- .../aio/operations/_api_policy_operations.py | 49 +- .../aio/operations/_api_product_operations.py | 16 +- .../aio/operations/_api_release_operations.py | 45 +- .../operations/_api_revision_operations.py | 16 +- .../aio/operations/_api_schema_operations.py | 67 +- .../_api_tag_description_operations.py | 40 +- .../operations/_api_version_set_operations.py | 45 +- .../aio/operations/_api_wiki_operations.py | 41 +- .../aio/operations/_api_wikis_operations.py | 16 +- ..._authorization_access_policy_operations.py | 37 +- .../_authorization_login_links_operations.py | 17 +- .../operations/_authorization_operations.py | 40 +- .../_authorization_provider_operations.py | 37 +- .../_authorization_server_operations.py | 50 +- .../aio/operations/_backend_operations.py | 48 +- .../aio/operations/_cache_operations.py | 45 +- .../aio/operations/_certificate_operations.py | 45 +- .../operations/_content_item_operations.py | 40 +- .../operations/_content_type_operations.py | 37 +- .../_delegation_settings_operations.py | 33 +- .../_deleted_services_operations.py | 45 +- .../aio/operations/_diagnostic_operations.py | 45 +- .../operations/_documentation_operations.py | 45 +- .../operations/_email_template_operations.py | 41 +- .../aio/operations/_gateway_api_operations.py | 31 +- ...ateway_certificate_authority_operations.py | 40 +- ...teway_hostname_configuration_operations.py | 40 +- .../aio/operations/_gateway_operations.py | 408 +- .../operations/_global_schema_operations.py | 67 +- .../_graph_ql_api_resolver_operations.py | 45 +- ...graph_ql_api_resolver_policy_operations.py | 40 +- .../aio/operations/_group_operations.py | 45 +- .../aio/operations/_group_user_operations.py | 31 +- .../_identity_provider_operations.py | 50 +- .../aio/operations/_issue_operations.py | 21 +- .../aio/operations/_logger_operations.py | 45 +- .../aio/operations/_named_value_operations.py | 124 +- .../operations/_network_status_operations.py | 22 +- .../operations/_notification_operations.py | 26 +- ...notification_recipient_email_operations.py | 32 +- ..._notification_recipient_user_operations.py | 32 +- .../_open_id_connect_provider_operations.py | 50 +- .../aio/operations/_operation_operations.py | 16 +- .../_operation_status_operations.py | 109 + .../_operations_results_operations.py | 112 + ...twork_dependencies_endpoints_operations.py | 17 +- .../_policy_description_operations.py | 17 +- .../operations/_policy_fragment_operations.py | 181 +- .../aio/operations/_policy_operations.py | 147 +- .../_policy_restriction_operations.py | 656 ++++ ...licy_restriction_validations_operations.py | 176 + .../operations/_portal_config_operations.py | 142 +- .../operations/_portal_revision_operations.py | 85 +- .../operations/_portal_settings_operations.py | 17 +- ..._private_endpoint_connection_operations.py | 89 +- .../_product_api_link_operations.py | 460 +++ .../aio/operations/_product_api_operations.py | 31 +- .../_product_group_link_operations.py | 460 +++ .../operations/_product_group_operations.py | 31 +- .../aio/operations/_product_operations.py | 49 +- .../operations/_product_policy_operations.py | 149 +- .../_product_subscriptions_operations.py | 16 +- .../operations/_product_wiki_operations.py | 41 +- .../operations/_product_wikis_operations.py | 16 +- .../_quota_by_counter_keys_operations.py | 22 +- .../_quota_by_period_keys_operations.py | 22 +- .../aio/operations/_region_operations.py | 16 +- .../aio/operations/_reports_operations.py | 44 +- .../_sign_in_settings_operations.py | 28 +- .../_sign_up_settings_operations.py | 28 +- .../operations/_subscription_operations.py | 56 +- .../operations/_tag_api_link_operations.py | 459 +++ .../_tag_operation_link_operations.py | 460 +++ .../aio/operations/_tag_operations.py | 121 +- .../_tag_product_link_operations.py | 460 +++ .../operations/_tag_resource_operations.py | 16 +- .../_tenant_access_git_operations.py | 18 +- .../operations/_tenant_access_operations.py | 45 +- .../_tenant_configuration_operations.py | 100 +- .../operations/_tenant_settings_operations.py | 21 +- .../_user_confirmation_password_operations.py | 15 +- .../aio/operations/_user_group_operations.py | 16 +- .../operations/_user_identities_operations.py | 16 +- .../aio/operations/_user_operations.py | 199 +- .../_user_subscription_operations.py | 21 +- .../_workspace_api_diagnostic_operations.py | 782 ++++ .../_workspace_api_export_operations.py | 136 + .../_workspace_api_operation_operations.py | 790 ++++ ...rkspace_api_operation_policy_operations.py | 612 +++ .../operations/_workspace_api_operations.py | 834 +++++ .../_workspace_api_policy_operations.py | 574 +++ .../_workspace_api_release_operations.py | 784 ++++ .../_workspace_api_revision_operations.py | 169 + .../_workspace_api_schema_operations.py | 676 ++++ .../_workspace_api_version_set_operations.py | 726 ++++ .../_workspace_backend_operations.py | 728 ++++ .../_workspace_certificate_operations.py | 646 ++++ .../_workspace_diagnostic_operations.py | 726 ++++ .../_workspace_global_schema_operations.py | 645 ++++ .../operations/_workspace_group_operations.py | 730 ++++ .../_workspace_group_user_operations.py | 381 ++ .../_workspace_logger_operations.py | 731 ++++ .../_workspace_named_value_operations.py | 1099 ++++++ .../_workspace_notification_operations.py | 314 ++ ...notification_recipient_email_operations.py | 356 ++ ..._notification_recipient_user_operations.py | 359 ++ .../aio/operations/_workspace_operations.py | 678 ++++ .../_workspace_policy_fragment_operations.py | 725 ++++ .../_workspace_policy_operations.py | 542 +++ .../_workspace_product_api_link_operations.py | 498 +++ ...workspace_product_group_link_operations.py | 498 +++ .../_workspace_product_operations.py | 744 ++++ .../_workspace_product_policy_operations.py | 544 +++ .../_workspace_subscription_operations.py | 1003 +++++ .../_workspace_tag_api_link_operations.py | 497 +++ ...workspace_tag_operation_link_operations.py | 498 +++ .../operations/_workspace_tag_operations.py | 724 ++++ .../_workspace_tag_product_link_operations.py | 498 +++ .../mgmt/apimanagement/models/__init__.py | 138 + .../models/_api_management_client_enums.py | 167 +- .../mgmt/apimanagement/models/_models_py3.py | 3307 +++++++++++++++-- .../mgmt/apimanagement/operations/__init__.py | 104 +- .../operations/_all_policies_operations.py | 183 + .../operations/_api_diagnostic_operations.py | 68 +- .../operations/_api_export_operations.py | 24 +- ...pi_gateway_config_connection_operations.py | 750 ++++ .../operations/_api_gateway_operations.py | 1020 +++++ .../_api_issue_attachment_operations.py | 59 +- .../_api_issue_comment_operations.py | 59 +- .../operations/_api_issue_operations.py | 68 +- .../_api_management_client_operations.py | 46 +- ..._api_management_gateway_skus_operations.py | 186 + .../_api_management_operations_operations.py | 17 +- .../_api_management_service_operations.py | 374 +- ..._api_management_service_skus_operations.py | 19 +- .../_api_management_skus_operations.py | 19 +- ...pi_management_workspace_link_operations.py | 162 + ...i_management_workspace_links_operations.py | 185 + .../operations/_api_operation_operations.py | 68 +- .../_api_operation_policy_operations.py | 60 +- .../operations/_api_operations.py | 225 +- .../operations/_api_policy_operations.py | 68 +- .../operations/_api_product_operations.py | 19 +- .../operations/_api_release_operations.py | 68 +- .../operations/_api_revision_operations.py | 19 +- .../operations/_api_schema_operations.py | 86 +- .../_api_tag_description_operations.py | 59 +- .../operations/_api_version_set_operations.py | 68 +- .../operations/_api_wiki_operations.py | 60 +- .../operations/_api_wikis_operations.py | 19 +- ..._authorization_access_policy_operations.py | 52 +- .../_authorization_login_links_operations.py | 20 +- .../operations/_authorization_operations.py | 59 +- .../_authorization_provider_operations.py | 52 +- .../_authorization_server_operations.py | 77 +- .../operations/_backend_operations.py | 75 +- .../operations/_cache_operations.py | 68 +- .../operations/_certificate_operations.py | 68 +- .../operations/_content_item_operations.py | 59 +- .../operations/_content_type_operations.py | 52 +- .../_delegation_settings_operations.py | 52 +- .../_deleted_services_operations.py | 56 +- .../operations/_diagnostic_operations.py | 68 +- .../operations/_documentation_operations.py | 68 +- .../operations/_email_template_operations.py | 64 +- .../operations/_gateway_api_operations.py | 46 +- ...ateway_certificate_authority_operations.py | 59 +- ...teway_hostname_configuration_operations.py | 59 +- .../operations/_gateway_operations.py | 569 ++- .../operations/_global_schema_operations.py | 86 +- .../_graph_ql_api_resolver_operations.py | 68 +- ...graph_ql_api_resolver_policy_operations.py | 59 +- .../operations/_group_operations.py | 68 +- .../operations/_group_user_operations.py | 46 +- .../_identity_provider_operations.py | 77 +- .../operations/_issue_operations.py | 28 +- .../operations/_logger_operations.py | 68 +- .../operations/_named_value_operations.py | 155 +- .../operations/_network_status_operations.py | 29 +- .../operations/_notification_operations.py | 37 +- ...notification_recipient_email_operations.py | 47 +- ..._notification_recipient_user_operations.py | 47 +- .../_open_id_connect_provider_operations.py | 77 +- .../operations/_operation_operations.py | 19 +- .../_operation_status_operations.py | 141 + .../_operations_results_operations.py | 144 + ...twork_dependencies_endpoints_operations.py | 20 +- .../_policy_description_operations.py | 20 +- .../operations/_policy_fragment_operations.py | 198 +- .../operations/_policy_operations.py | 162 +- .../_policy_restriction_operations.py | 935 +++++ ...licy_restriction_validations_operations.py | 216 ++ .../operations/_portal_config_operations.py | 155 +- .../operations/_portal_revision_operations.py | 104 +- .../operations/_portal_settings_operations.py | 20 +- ..._private_endpoint_connection_operations.py | 112 +- .../_product_api_link_operations.py | 646 ++++ .../operations/_product_api_operations.py | 46 +- .../_product_group_link_operations.py | 661 ++++ .../operations/_product_group_operations.py | 46 +- .../operations/_product_operations.py | 76 +- .../operations/_product_policy_operations.py | 162 +- .../_product_subscriptions_operations.py | 19 +- .../operations/_product_wiki_operations.py | 60 +- .../operations/_product_wikis_operations.py | 19 +- .../_quota_by_counter_keys_operations.py | 29 +- .../_quota_by_period_keys_operations.py | 29 +- .../operations/_region_operations.py | 19 +- .../operations/_reports_operations.py | 75 +- .../_sign_in_settings_operations.py | 43 +- .../_sign_up_settings_operations.py | 43 +- .../operations/_subscription_operations.py | 91 +- .../operations/_tag_api_link_operations.py | 645 ++++ .../_tag_operation_link_operations.py | 661 ++++ .../operations/_tag_operations.py | 204 +- .../_tag_product_link_operations.py | 646 ++++ .../operations/_tag_resource_operations.py | 19 +- .../_tenant_access_git_operations.py | 25 +- .../operations/_tenant_access_operations.py | 76 +- .../_tenant_configuration_operations.py | 115 +- .../operations/_tenant_settings_operations.py | 28 +- .../_user_confirmation_password_operations.py | 18 +- .../operations/_user_group_operations.py | 19 +- .../operations/_user_identities_operations.py | 19 +- .../operations/_user_operations.py | 230 +- .../_user_subscription_operations.py | 28 +- .../_workspace_api_diagnostic_operations.py | 1116 ++++++ .../_workspace_api_export_operations.py | 193 + .../_workspace_api_operation_operations.py | 1117 ++++++ ...rkspace_api_operation_policy_operations.py | 884 +++++ .../operations/_workspace_api_operations.py | 1146 ++++++ .../_workspace_api_policy_operations.py | 831 +++++ .../_workspace_api_release_operations.py | 1118 ++++++ .../_workspace_api_revision_operations.py | 230 ++ .../_workspace_api_schema_operations.py | 947 +++++ .../_workspace_api_version_set_operations.py | 1048 ++++++ .../_workspace_backend_operations.py | 1030 +++++ .../_workspace_certificate_operations.py | 967 +++++ .../_workspace_diagnostic_operations.py | 1048 ++++++ .../_workspace_global_schema_operations.py | 890 +++++ .../operations/_workspace_group_operations.py | 1033 +++++ .../_workspace_group_user_operations.py | 590 +++ .../_workspace_logger_operations.py | 1033 +++++ .../_workspace_named_value_operations.py | 1526 ++++++++ .../_workspace_notification_operations.py | 467 +++ ...notification_recipient_email_operations.py | 556 +++ ..._notification_recipient_user_operations.py | 559 +++ .../operations/_workspace_operations.py | 966 +++++ .../_workspace_policy_fragment_operations.py | 1037 ++++++ .../_workspace_policy_operations.py | 790 ++++ .../_workspace_product_api_link_operations.py | 715 ++++ ...workspace_product_group_link_operations.py | 715 ++++ .../_workspace_product_operations.py | 1055 ++++++ .../_workspace_product_policy_operations.py | 803 ++++ .../_workspace_subscription_operations.py | 1446 +++++++ .../_workspace_tag_api_link_operations.py | 714 ++++ ...workspace_tag_operation_link_operations.py | 715 ++++ .../operations/_workspace_tag_operations.py | 1030 +++++ .../_workspace_tag_product_link_operations.py | 715 ++++ .../api_management_all_policies.py | 43 + ...ent_apply_network_configuration_updates.py | 4 +- ...e_or_reject_private_endpoint_connection.py | 8 +- ...ement_authorization_server_list_secrets.py | 4 +- .../api_management_backend_reconnect.py | 4 +- .../api_management_backup_with_access_key.py | 6 +- ...ent_backup_with_system_managed_identity.py | 6 +- ...kup_with_user_assigned_managed_identity.py | 6 +- .../api_management_create_ai_logger.py | 6 +- .../api_management_create_api.py | 6 +- .../api_management_create_api_clone.py | 8 +- .../api_management_create_api_diagnostic.py | 6 +- .../api_management_create_api_issue.py | 8 +- ..._management_create_api_issue_attachment.py | 6 +- ...api_management_create_api_issue_comment.py | 8 +- ...eate_api_new_version_using_existing_api.py | 10 +- .../api_management_create_api_operation.py | 6 +- ..._management_create_api_operation_policy.py | 9 +- ...api_management_create_api_operation_tag.py | 4 +- .../api_management_create_api_policy.py | 9 +- ...ement_create_api_policy_non_xml_encoded.py | 9 +- .../api_management_create_api_release.py | 8 +- ...t_create_api_revision_from_existing_api.py | 8 +- .../api_management_create_api_schema.py | 6 +- .../api_management_create_api_tag.py | 4 +- ...i_management_create_api_tag_description.py | 6 +- ...e_api_using_import_override_service_url.py | 6 +- ...management_create_api_using_oai3_import.py | 6 +- ...slate_required_query_parameters_conduct.py | 6 +- ...agement_create_api_using_swagger_import.py | 6 +- ...management_create_api_using_wadl_import.py | 6 +- .../api_management_create_api_version_set.py | 6 +- .../api_management_create_api_wiki.py | 6 +- ...t_create_api_with_multiple_auth_servers.py | 6 +- ...with_multiple_open_id_connect_providers.py | 6 +- ...agement_create_api_with_open_id_connect.py | 6 +- ...ment_create_authorization_aad_auth_code.py | 6 +- ...nt_create_authorization_aad_client_cred.py | 11 +- ...ment_create_authorization_access_policy.py | 7 +- ...te_authorization_provider_aad_auth_code.py | 10 +- ..._authorization_provider_aad_client_cred.py | 6 +- ...e_authorization_provider_generic_oauth2.py | 12 +- ...reate_authorization_provider_oob_google.py | 10 +- ..._management_create_authorization_server.py | 6 +- ...management_create_backend_proxy_backend.py | 6 +- ...anagement_create_backend_service_fabric.py | 8 +- .../api_management_create_cache.py | 8 +- .../api_management_create_certificate.py | 6 +- ...ement_create_certificate_with_key_vault.py | 6 +- .../api_management_create_content_type.py | 6 +- ...gement_create_content_type_content_item.py | 6 +- .../api_management_create_diagnostic.py | 6 +- .../api_management_create_documentation.py | 6 +- .../api_management_create_eh_logger.py | 6 +- .../api_management_create_gateway.py | 6 +- .../api_management_create_gateway_api.py | 4 +- ...nt_create_gateway_certificate_authority.py | 6 +- ...gement_create_gateway_config_connection.py | 48 + ...t_create_gateway_hostname_configuration.py | 8 +- .../api_management_create_global_schema1.py | 6 +- .../api_management_create_global_schema2.py | 6 +- .../api_management_create_graph_ql_api.py | 6 +- ...management_create_graph_ql_api_resolver.py | 6 +- ...ent_create_graph_ql_api_resolver_policy.py | 9 +- .../api_management_create_group.py | 6 +- .../api_management_create_group_external.py | 6 +- .../api_management_create_group_user.py | 4 +- .../api_management_create_grpc_api.py | 55 + ...api_management_create_identity_provider.py | 9 +- ...lti_region_service_with_custom_hostname.py | 12 +- .../api_management_create_named_value.py | 6 +- ...ement_create_named_value_with_key_vault.py | 6 +- .../api_management_create_notification.py | 9 +- ...ent_create_notification_recipient_email.py | 9 +- ...ment_create_notification_recipient_user.py | 9 +- .../api_management_create_odata_api.py | 55 + ...agement_create_open_id_connect_provider.py | 6 +- .../api_management_create_policy.py | 9 +- .../api_management_create_policy_fragment.py | 6 +- ...pi_management_create_policy_restriction.py | 44 + .../api_management_create_portal_config.py | 6 +- .../api_management_create_portal_revision.py | 6 +- .../api_management_create_product.py | 6 +- .../api_management_create_product_api.py | 4 +- .../api_management_create_product_api_link.py | 49 + .../api_management_create_product_group.py | 4 +- ...pi_management_create_product_group_link.py | 49 + .../api_management_create_product_policy.py | 9 +- .../api_management_create_product_tag.py | 4 +- .../api_management_create_product_wiki.py | 6 +- .../api_management_create_service.py | 6 +- ...pi_management_create_service_having_msi.py | 6 +- ...t_create_service_in_vnet_with_public_ip.py | 10 +- .../api_management_create_service_in_zones.py | 6 +- ...management_create_service_skuv2_service.py | 49 + ..._service_with_custom_hostname_key_vault.py | 14 +- ...nt_create_service_with_developer_portal.py | 52 + ...create_service_with_nat_gateway_enabled.py | 6 +- ...create_service_with_system_certificates.py | 6 +- ...ate_service_with_user_assigned_identity.py | 8 +- ...ervice_without_legacy_configuration_api.py | 52 + ...soap_pass_through_api_using_wsdl_import.py | 6 +- ...eate_soap_to_rest_api_using_wsdl_import.py | 6 +- .../api_management_create_standard_gateway.py | 54 + .../api_management_create_subscription.py | 10 +- .../api_management_create_tag.py | 6 +- .../api_management_create_tag_api_link.py | 49 + ...pi_management_create_tag_operation_link.py | 49 + .../api_management_create_tag_product_link.py | 49 + .../api_management_create_template.py | 9 +- .../api_management_create_tenant_access.py | 9 +- .../api_management_create_user.py | 6 +- .../api_management_create_websocket_api.py | 6 +- .../api_management_create_workspace.py | 44 + ...i_management_create_workspace_ai_logger.py | 51 + .../api_management_create_workspace_api.py | 57 + ...agement_create_workspace_api_diagnostic.py | 60 + ...nagement_create_workspace_api_operation.py | 70 + ...t_create_workspace_api_operation_policy.py | 52 + ..._management_create_workspace_api_policy.py | 51 + ...management_create_workspace_api_release.py | 51 + ..._management_create_workspace_api_schema.py | 53 + ...gement_create_workspace_api_version_set.py | 51 + ..._create_workspace_backend_proxy_backend.py | 58 + ...create_workspace_backend_service_fabric.py | 61 + ...management_create_workspace_certificate.py | 50 + ...te_workspace_certificate_with_key_vault.py | 52 + ..._management_create_workspace_diagnostic.py | 59 + ...i_management_create_workspace_eh_logger.py | 54 + .../api_management_create_workspace_group.py | 45 + ...agement_create_workspace_group_external.py | 52 + ..._management_create_workspace_group_user.py | 45 + ...management_create_workspace_named_value.py | 47 + ...te_workspace_named_value_with_key_vault.py | 55 + ...anagement_create_workspace_notification.py | 44 + ..._workspace_notification_recipient_email.py | 45 + ...e_workspace_notification_recipient_user.py | 45 + .../api_management_create_workspace_policy.py | 50 + ...gement_create_workspace_policy_fragment.py | 51 + ...create_workspace_policy_non_xml_encoded.py | 50 + ...gement_create_workspace_premium_gateway.py | 55 + ...api_management_create_workspace_product.py | 45 + ...ement_create_workspace_product_api_link.py | 50 + ...ent_create_workspace_product_group_link.py | 50 + ...agement_create_workspace_product_policy.py | 51 + .../api_management_create_workspace_schema.py | 51 + ...anagement_create_workspace_subscription.py | 51 + .../api_management_create_workspace_tag.py | 45 + ...anagement_create_workspace_tag_api_link.py | 50 + ...ent_create_workspace_tag_operation_link.py | 50 + ...ement_create_workspace_tag_product_link.py | 50 + .../api_management_delete_api.py | 8 +- .../api_management_delete_api_diagnostic.py | 4 +- .../api_management_delete_api_issue.py | 4 +- ..._management_delete_api_issue_attachment.py | 4 +- ...api_management_delete_api_issue_comment.py | 4 +- .../api_management_delete_api_operation.py | 4 +- ..._management_delete_api_operation_policy.py | 9 +- ...api_management_delete_api_operation_tag.py | 4 +- .../api_management_delete_api_policy.py | 9 +- .../api_management_delete_api_release.py | 4 +- .../api_management_delete_api_schema.py | 4 +- .../api_management_delete_api_tag.py | 4 +- ...i_management_delete_api_tag_description.py | 4 +- .../api_management_delete_api_version_set.py | 4 +- .../api_management_delete_api_wiki.py | 4 +- .../api_management_delete_authorization.py | 4 +- ...ment_delete_authorization_access_policy.py | 4 +- ...anagement_delete_authorization_provider.py | 4 +- ..._management_delete_authorization_server.py | 4 +- .../api_management_delete_backend.py | 4 +- .../api_management_delete_cache.py | 4 +- .../api_management_delete_certificate.py | 4 +- .../api_management_delete_content_type.py | 4 +- ...gement_delete_content_type_content_item.py | 4 +- .../api_management_delete_diagnostic.py | 4 +- .../api_management_delete_gateway.py | 4 +- .../api_management_delete_gateway_api.py | 4 +- ...nt_delete_gateway_certificate_authority.py | 4 +- ...gement_delete_gateway_config_connection.py | 43 + ...t_delete_gateway_hostname_configuration.py | 4 +- .../api_management_delete_global_schema.py | 4 +- ...management_delete_graph_ql_api_resolver.py | 4 +- ...ent_delete_graph_ql_api_resolver_policy.py | 9 +- .../api_management_delete_group.py | 4 +- .../api_management_delete_group_user.py | 4 +- ...api_management_delete_identity_provider.py | 9 +- .../api_management_delete_logger.py | 4 +- .../api_management_delete_named_value.py | 4 +- ...ent_delete_notification_recipient_email.py | 9 +- ...ment_delete_notification_recipient_user.py | 9 +- ...agement_delete_open_id_connect_provider.py | 4 +- .../api_management_delete_policy.py | 9 +- .../api_management_delete_policy_fragment.py | 4 +- ...pi_management_delete_policy_restriction.py | 42 + ...ment_delete_private_endpoint_connection.py | 4 +- .../api_management_delete_product.py | 4 +- .../api_management_delete_product_api.py | 4 +- .../api_management_delete_product_api_link.py | 43 + .../api_management_delete_product_group.py | 4 +- ...pi_management_delete_product_group_link.py | 43 + .../api_management_delete_product_policy.py | 9 +- .../api_management_delete_product_tag.py | 4 +- .../api_management_delete_product_wiki.py | 4 +- .../api_management_delete_subscription.py | 4 +- .../api_management_delete_tag.py | 4 +- .../api_management_delete_tag_api_link.py | 43 + ...pi_management_delete_tag_operation_link.py | 43 + .../api_management_delete_tag_product_link.py | 43 + .../api_management_delete_template.py | 9 +- .../api_management_delete_user.py | 8 +- ....py => api_management_delete_workspace.py} | 10 +- .../api_management_delete_workspace_api.py | 44 + ...agement_delete_workspace_api_diagnostic.py | 45 + ...nagement_delete_workspace_api_operation.py | 45 + ...t_delete_workspace_api_operation_policy.py | 46 + ..._management_delete_workspace_api_policy.py | 45 + ...management_delete_workspace_api_release.py | 45 + ..._management_delete_workspace_api_schema.py | 45 + ...gement_delete_workspace_api_version_set.py | 44 + ...api_management_delete_workspace_backend.py | 44 + ...management_delete_workspace_certificate.py | 44 + ..._management_delete_workspace_diagnostic.py | 44 + .../api_management_delete_workspace_group.py | 44 + ..._management_delete_workspace_group_user.py | 44 + .../api_management_delete_workspace_logger.py | 44 + ...management_delete_workspace_named_value.py | 44 + ..._workspace_notification_recipient_email.py | 44 + ...e_workspace_notification_recipient_user.py | 44 + .../api_management_delete_workspace_policy.py | 44 + ...gement_delete_workspace_policy_fragment.py | 44 + ...api_management_delete_workspace_product.py | 44 + ...ement_delete_workspace_product_api_link.py | 44 + ...ent_delete_workspace_product_group_link.py | 44 + ...agement_delete_workspace_product_policy.py | 45 + .../api_management_delete_workspace_schema.py | 44 + ...anagement_delete_workspace_subscription.py | 44 + .../api_management_delete_workspace_tag.py | 44 + ...anagement_delete_workspace_tag_api_link.py | 44 + ...ent_delete_workspace_tag_operation_link.py | 44 + ...ement_delete_workspace_tag_product_link.py | 44 + ...t_deleted_services_list_by_subscription.py | 4 +- .../api_management_deleted_services_purge.py | 4 +- .../api_management_gateway_delete_gateway.py | 42 + .../api_management_gateway_generate_token.py | 6 +- .../api_management_gateway_get_gateway.py | 42 + ...nt_gateway_invalidate_debug_credentials.py | 42 + ...nagement_gateway_list_debug_credentials.py | 48 + .../api_management_gateway_list_keys.py | 4 +- .../api_management_gateway_list_trace.py | 44 + .../api_management_gateway_regenerate_key.py | 6 +- .../api_management_get_api_contract.py | 4 +- .../api_management_get_api_diagnostic.py | 4 +- ...agement_get_api_export_in_open_api2dot0.py | 9 +- ...agement_get_api_export_in_open_api3dot0.py | 9 +- .../api_management_get_api_issue.py | 4 +- ...api_management_get_api_issue_attachment.py | 4 +- .../api_management_get_api_issue_comment.py | 4 +- .../api_management_get_api_operation.py | 4 +- ..._management_get_api_operation_pet_store.py | 4 +- ...api_management_get_api_operation_policy.py | 9 +- .../api_management_get_api_operation_tag.py | 4 +- .../api_management_get_api_policy.py | 9 +- .../api_management_get_api_release.py | 4 +- .../api_management_get_api_revision.py | 4 +- .../api_management_get_api_schema.py | 4 +- .../api_management_get_api_tag.py | 4 +- .../api_management_get_api_tag_description.py | 4 +- .../api_management_get_api_version_set.py | 4 +- .../api_management_get_api_wiki.py | 4 +- .../api_management_get_authorization.py | 4 +- ...agement_get_authorization_access_policy.py | 4 +- ...agement_get_authorization_login_request.py | 6 +- ...i_management_get_authorization_provider.py | 4 +- ...api_management_get_authorization_server.py | 4 +- .../api_management_get_backend.py | 4 +- .../api_management_get_cache.py | 4 +- .../api_management_get_certificate.py | 4 +- ...nagement_get_certificate_with_key_vault.py | 4 +- .../api_management_get_content_type.py | 4 +- ...anagement_get_content_type_content_item.py | 4 +- ..._management_get_deleted_service_by_name.py | 4 +- .../api_management_get_diagnostic.py | 4 +- .../api_management_get_documentation.py | 4 +- .../api_management_get_gateway.py | 4 +- ...ement_get_gateway_certificate_authority.py | 4 +- ...anagement_get_gateway_config_connection.py | 43 + ...ment_get_gateway_hostname_configuration.py | 4 +- .../api_management_get_global_schema1.py | 4 +- .../api_management_get_global_schema2.py | 4 +- ...pi_management_get_graph_ql_api_resolver.py | 4 +- ...gement_get_graph_ql_api_resolver_policy.py | 9 +- .../api_management_get_group.py | 4 +- .../api_management_get_identity_provider.py | 9 +- .../api_management_get_issue.py | 4 +- .../api_management_get_logger.py | 4 +- .../api_management_get_named_value.py | 4 +- ...nagement_get_named_value_with_key_vault.py | 4 +- .../api_management_get_notification.py | 9 +- ...management_get_open_id_connect_provider.py | 4 +- .../api_management_get_operation_result.py | 41 + .../api_management_get_operation_status.py | 42 + .../api_management_get_policy.py | 9 +- .../api_management_get_policy_format.py | 9 +- .../api_management_get_policy_fragment.py | 4 +- ...i_management_get_policy_fragment_format.py | 4 +- .../api_management_get_policy_restriction.py | 43 + .../api_management_get_portal_revision.py | 4 +- ...agement_get_private_endpoint_connection.py | 4 +- ...agement_get_private_link_group_resource.py | 4 +- .../api_management_get_product.py | 4 +- .../api_management_get_product_api_link.py | 44 + .../api_management_get_product_group_link.py | 44 + .../api_management_get_product_policy.py | 9 +- .../api_management_get_product_tag.py | 4 +- .../api_management_get_product_wiki.py | 4 +- .../api_management_get_quota_counter_keys.py | 4 +- ..._get_quota_counter_keys_by_quota_period.py | 4 +- .../api_management_get_reports_by_api.py | 44 + .../api_management_get_reports_by_geo.py | 44 + ...api_management_get_reports_by_operation.py | 44 + .../api_management_get_reports_by_product.py | 44 + .../api_management_get_reports_by_request.py | 44 + ..._management_get_reports_by_subscription.py | 44 + .../api_management_get_reports_by_time.py | 47 + .../api_management_get_reports_by_user.py | 44 + .../api_management_get_subscription.py | 4 +- .../api_management_get_tag.py | 4 +- .../api_management_get_tag_api_link.py | 44 + .../api_management_get_tag_operation_link.py | 44 + .../api_management_get_tag_product_link.py | 44 + .../api_management_get_template.py | 9 +- .../api_management_get_tenant_access.py | 9 +- .../api_management_get_tenant_git_access.py | 9 +- .../api_management_get_tenant_settings.py | 9 +- .../api_management_get_user.py | 4 +- .../api_management_get_user_subscription.py | 4 +- .../api_management_get_workspace.py | 43 + ...i_management_get_workspace_api_contract.py | 44 + ...management_get_workspace_api_diagnostic.py | 45 + ...t_workspace_api_export_in_open_api2dot0.py | 46 + ...t_workspace_api_export_in_open_api3dot0.py | 46 + ..._management_get_workspace_api_operation.py | 45 + ...ment_get_workspace_api_operation_policy.py | 46 + ...api_management_get_workspace_api_policy.py | 45 + ...pi_management_get_workspace_api_release.py | 45 + ...i_management_get_workspace_api_revision.py | 44 + ...api_management_get_workspace_api_schema.py | 45 + ...anagement_get_workspace_api_version_set.py | 44 + .../api_management_get_workspace_backend.py | 44 + ...pi_management_get_workspace_certificate.py | 44 + ...et_workspace_certificate_with_key_vault.py | 44 + ...api_management_get_workspace_diagnostic.py | 44 + .../api_management_get_workspace_group.py | 44 + .../api_management_get_workspace_link.py | 43 + .../api_management_get_workspace_logger.py | 44 + ...pi_management_get_workspace_named_value.py | 44 + ...et_workspace_named_value_with_key_vault.py | 44 + ...i_management_get_workspace_notification.py | 44 + .../api_management_get_workspace_policy.py | 44 + ...anagement_get_workspace_policy_fragment.py | 44 + ...nt_get_workspace_policy_fragment_format.py | 44 + .../api_management_get_workspace_product.py | 44 + ...nagement_get_workspace_product_api_link.py | 45 + ...gement_get_workspace_product_group_link.py | 45 + ...management_get_workspace_product_policy.py | 45 + .../api_management_get_workspace_schema.py | 44 + ...i_management_get_workspace_subscription.py | 44 + .../api_management_get_workspace_tag.py | 44 + ...i_management_get_workspace_tag_api_link.py | 45 + ...gement_get_workspace_tag_operation_link.py | 45 + ...nagement_get_workspace_tag_product_link.py | 45 + .../api_management_head_api.py | 4 +- .../api_management_head_api_diagnostic.py | 4 +- .../api_management_head_api_issue.py | 4 +- ...pi_management_head_api_issue_attachment.py | 4 +- .../api_management_head_api_issue_comment.py | 4 +- .../api_management_head_api_operation.py | 4 +- ...pi_management_head_api_operation_policy.py | 9 +- .../api_management_head_api_operation_tag.py | 4 +- .../api_management_head_api_policy.py | 9 +- .../api_management_head_api_release.py | 4 +- .../api_management_head_api_schema.py | 4 +- .../api_management_head_api_tag.py | 4 +- ...api_management_head_api_tag_description.py | 4 +- .../api_management_head_api_version_set.py | 4 +- .../api_management_head_api_wiki.py | 4 +- ...pi_management_head_authorization_server.py | 4 +- .../api_management_head_backend.py | 4 +- .../api_management_head_cache.py | 4 +- .../api_management_head_certificate.py | 4 +- ...nagement_head_content_type_content_item.py | 4 +- ...api_management_head_delegation_settings.py | 4 +- .../api_management_head_diagnostic.py | 4 +- .../api_management_head_documentation.py | 4 +- .../api_management_head_email_template.py | 9 +- .../api_management_head_gateway.py | 4 +- .../api_management_head_gateway_api.py | 4 +- ...ment_head_gateway_certificate_authority.py | 4 +- ...ent_head_gateway_hostname_configuration.py | 4 +- .../api_management_head_global_schema.py | 4 +- ...i_management_head_graph_ql_api_resolver.py | 4 +- ...ement_head_graph_ql_api_resolver_policy.py | 9 +- .../api_management_head_group.py | 4 +- .../api_management_head_group_user.py | 4 +- .../api_management_head_identity_provider.py | 9 +- .../api_management_head_logger.py | 4 +- .../api_management_head_named_value.py | 4 +- ...ement_head_notification_recipient_email.py | 9 +- ...gement_head_notification_recipient_user.py | 9 +- ...anagement_head_open_id_connect_provider.py | 4 +- .../api_management_head_policy.py | 9 +- .../api_management_head_policy_fragment.py | 4 +- .../api_management_head_policy_restriction.py | 43 + .../api_management_head_portal_config.py | 4 +- .../api_management_head_portal_revision.py | 4 +- .../api_management_head_product.py | 4 +- .../api_management_head_product_api.py | 4 +- .../api_management_head_product_group.py | 4 +- .../api_management_head_product_policy.py | 9 +- .../api_management_head_product_tag.py | 4 +- .../api_management_head_product_wiki.py | 4 +- .../api_management_head_sign_in_settings.py | 4 +- .../api_management_head_sign_up_settings.py | 4 +- .../api_management_head_subscription.py | 4 +- .../api_management_head_tag.py | 4 +- .../api_management_head_tenant_access.py | 9 +- .../api_management_head_user.py | 4 +- .../api_management_head_workspace.py | 43 + .../api_management_head_workspace_api.py | 44 + ...anagement_head_workspace_api_diagnostic.py | 45 + ...management_head_workspace_api_operation.py | 45 + ...ent_head_workspace_api_operation_policy.py | 46 + ...pi_management_head_workspace_api_policy.py | 45 + ...i_management_head_workspace_api_release.py | 45 + ...pi_management_head_workspace_api_schema.py | 45 + ...nagement_head_workspace_api_version_set.py | 44 + .../api_management_head_workspace_backend.py | 44 + ...i_management_head_workspace_certificate.py | 44 + ...pi_management_head_workspace_diagnostic.py | 44 + .../api_management_head_workspace_group.py | 44 + ...pi_management_head_workspace_group_user.py | 45 + .../api_management_head_workspace_logger.py | 44 + ...i_management_head_workspace_named_value.py | 44 + ..._workspace_notification_recipient_email.py | 45 + ...d_workspace_notification_recipient_user.py | 45 + .../api_management_head_workspace_policy.py | 44 + ...nagement_head_workspace_policy_fragment.py | 44 + .../api_management_head_workspace_product.py | 44 + ...anagement_head_workspace_product_policy.py | 45 + .../api_management_head_workspace_schema.py | 44 + ..._management_head_workspace_subscription.py | 44 + .../api_management_head_workspace_tag.py | 44 + ...nagement_identity_provider_list_secrets.py | 9 +- .../api_management_list_api_diagnostics.py | 4 +- ...i_management_list_api_issue_attachments.py | 4 +- .../api_management_list_api_issue_comments.py | 4 +- .../api_management_list_api_issues.py | 4 +- ..._management_list_api_operation_policies.py | 4 +- .../api_management_list_api_operation_tags.py | 4 +- .../api_management_list_api_operations.py | 4 +- ..._management_list_api_operations_by_tags.py | 4 +- .../api_management_list_api_policies.py | 4 +- .../api_management_list_api_products.py | 4 +- .../api_management_list_api_releases.py | 4 +- .../api_management_list_api_revisions.py | 4 +- .../api_management_list_api_schemas.py | 4 +- ...pi_management_list_api_tag_descriptions.py | 4 +- .../api_management_list_api_tags.py | 4 +- .../api_management_list_api_version_sets.py | 4 +- .../api_management_list_api_wikis.py | 4 +- .../api_management_list_apis.py | 4 +- .../api_management_list_apis_by_tags.py | 4 +- ...ment_list_authorization_access_policies.py | 4 +- ...management_list_authorization_providers.py | 4 +- ...i_management_list_authorization_servers.py | 4 +- ...anagement_list_authorizations_auth_code.py | 4 +- ...agement_list_authorizations_client_cred.py | 4 +- .../api_management_list_backends.py | 4 +- .../api_management_list_caches.py | 4 +- .../api_management_list_certificates.py | 4 +- ...agement_list_content_type_content_items.py | 4 +- .../api_management_list_content_types.py | 4 +- .../api_management_list_diagnostics.py | 4 +- .../api_management_list_documentations.py | 4 +- .../api_management_list_gateway_apis.py | 4 +- ...nt_list_gateway_certificate_authorities.py | 4 +- ...nagement_list_gateway_config_connection.py | 43 + ...nt_list_gateway_hostname_configurations.py | 4 +- .../api_management_list_gateways.py | 4 +- ...anagement_list_gateways_by_subscription.py | 40 + ...ways_by_subscription_and_resource_group.py | 42 + .../api_management_list_global_schemas.py | 4 +- ...ent_list_graph_ql_api_resolver_policies.py | 4 +- ..._management_list_graph_ql_api_resolvers.py | 4 +- .../api_management_list_group_users.py | 4 +- .../api_management_list_groups.py | 4 +- .../api_management_list_identity_providers.py | 4 +- .../api_management_list_issues.py | 4 +- .../api_management_list_loggers.py | 4 +- .../api_management_list_named_values.py | 4 +- ...ment_list_notification_recipient_emails.py | 9 +- ...ement_list_notification_recipient_users.py | 9 +- .../api_management_list_notifications.py | 4 +- ...nagement_list_open_id_connect_providers.py | 4 +- .../api_management_list_operations.py | 2 +- .../api_management_list_policies.py | 7 +- ...api_management_list_policy_descriptions.py | 4 +- ...agement_list_policy_fragment_references.py | 4 +- .../api_management_list_policy_fragments.py | 7 +- ...api_management_list_policy_restrictions.py | 43 + .../api_management_list_portal_config.py | 7 +- .../api_management_list_portal_revisions.py | 4 +- .../api_management_list_portal_settings.py | 4 +- ...ement_list_private_endpoint_connections.py | 4 +- ...ement_list_private_link_group_resources.py | 4 +- .../api_management_list_product_api_links.py | 44 + .../api_management_list_product_apis.py | 4 +- ...api_management_list_product_group_links.py | 44 + .../api_management_list_product_groups.py | 4 +- .../api_management_list_product_policies.py | 7 +- ...i_management_list_product_subscriptions.py | 4 +- .../api_management_list_product_tags.py | 4 +- .../api_management_list_product_wikis.py | 4 +- .../api_management_list_products.py | 4 +- .../api_management_list_products_by_tags.py | 4 +- .../api_management_list_regions.py | 4 +- ..._secrets_portal_settings_validation_key.py | 4 +- ...i_management_list_secrets_tenant_access.py | 9 +- ...management_list_service_by_subscription.py | 4 +- ...vice_by_subscription_and_resource_group.py | 4 +- .../api_management_list_sk_us_consumption.py | 4 +- .../api_management_list_sk_us_dedicated.py | 4 +- .../api_management_list_sk_us_gateways.py | 43 + .../api_management_list_sku.py | 4 +- .../api_management_list_subscriptions.py | 4 +- .../api_management_list_tag_api_links.py | 44 + ...api_management_list_tag_operation_links.py | 44 + .../api_management_list_tag_product_links.py | 44 + .../api_management_list_tag_resources.py | 4 +- .../api_management_list_tags.py | 4 +- .../api_management_list_templates.py | 4 +- .../api_management_list_tenant_access.py | 4 +- .../api_management_list_tenant_settings.py | 4 +- .../api_management_list_user_groups.py | 4 +- .../api_management_list_user_identities.py | 4 +- .../api_management_list_user_subscriptions.py | 4 +- .../api_management_list_users.py | 4 +- ...nagement_list_workspace_api_diagnostics.py | 45 + ...t_list_workspace_api_operation_policies.py | 46 + ...anagement_list_workspace_api_operations.py | 45 + ..._management_list_workspace_api_policies.py | 45 + ..._management_list_workspace_api_releases.py | 45 + ...management_list_workspace_api_revisions.py | 45 + ...i_management_list_workspace_api_schemas.py | 45 + ...agement_list_workspace_api_version_sets.py | 44 + .../api_management_list_workspace_apis.py | 44 + .../api_management_list_workspace_backends.py | 44 + ..._management_list_workspace_certificates.py | 44 + ...i_management_list_workspace_diagnostics.py | 44 + ...i_management_list_workspace_group_users.py | 45 + .../api_management_list_workspace_groups.py | 44 + .../api_management_list_workspace_links.py | 43 + .../api_management_list_workspace_loggers.py | 44 + ..._management_list_workspace_named_values.py | 44 + ...workspace_notification_recipient_emails.py | 44 + ..._workspace_notification_recipient_users.py | 44 + ...management_list_workspace_notifications.py | 44 + .../api_management_list_workspace_policies.py | 44 + ...st_workspace_policy_fragment_references.py | 44 + ...agement_list_workspace_policy_fragments.py | 44 + ...gement_list_workspace_product_api_links.py | 45 + ...ment_list_workspace_product_group_links.py | 45 + ...agement_list_workspace_product_policies.py | 44 + .../api_management_list_workspace_products.py | 44 + .../api_management_list_workspace_schemas.py | 44 + ...management_list_workspace_subscriptions.py | 44 + ...management_list_workspace_tag_api_links.py | 45 + ...ment_list_workspace_tag_operation_links.py | 45 + ...gement_list_workspace_tag_product_links.py | 45 + .../api_management_list_workspace_tags.py | 44 + .../api_management_list_workspaces.py | 43 + .../api_management_named_value_list_value.py | 4 +- ...nt_openid_connect_provider_list_secrets.py | 4 +- ...i_management_perform_connectivity_check.py | 6 +- ...perform_connectivity_check_http_connect.py | 8 +- .../api_management_portal_config.py | 4 +- ...nagement_portal_settings_get_delegation.py | 4 +- ..._management_portal_settings_get_sign_in.py | 4 +- ..._management_portal_settings_get_sign_up.py | 4 +- ...nagement_portal_settings_put_delegation.py | 6 +- ..._management_portal_settings_put_sign_in.py | 6 +- ..._management_portal_settings_put_sign_up.py | 6 +- ...ement_portal_settings_update_delegation.py | 6 +- ...nagement_portal_settings_update_sign_in.py | 6 +- ...nagement_portal_settings_update_sign_up.py | 6 +- ...horization_confirm_consent_code_request.py | 6 +- .../api_management_refresh_certificate.py | 4 +- .../api_management_refresh_named_value.py | 4 +- ...anagement_refresh_workspace_certificate.py | 44 + ...anagement_refresh_workspace_named_value.py | 44 + .../api_management_restore_with_access_key.py | 6 +- ...agement_service_check_name_availability.py | 6 +- .../api_management_service_delete_service.py | 4 +- ...service_get_domain_ownership_identifier.py | 4 +- ..._service_get_multi_region_internal_vnet.py | 4 +- ...i_management_service_get_network_status.py | 4 +- ..._service_get_network_status_by_location.py | 4 +- ...outbound_network_dependencies_endpoints.py | 4 +- .../api_management_service_get_service.py | 4 +- ...nagement_service_get_service_having_msi.py | 4 +- .../api_management_service_get_sso_token.py | 4 +- .../api_management_service_migrate_to_stv2.py | 4 +- ...pi_management_subscription_list_secrets.py | 4 +- ...ent_subscription_regenerate_primary_key.py | 4 +- ...t_subscription_regenerate_secondary_key.py | 4 +- ...management_tenant_access_regenerate_key.py | 11 +- ...api_management_tenant_access_sync_state.py | 9 +- ..._management_tenant_configuration_deploy.py | 9 +- ...pi_management_tenant_configuration_save.py | 9 +- ...anagement_tenant_configuration_validate.py | 9 +- .../api_management_undelete.py | 6 +- .../api_management_update_api.py | 6 +- .../api_management_update_api_diagnostic.py | 6 +- .../api_management_update_api_issue.py | 6 +- .../api_management_update_api_operation.py | 6 +- .../api_management_update_api_release.py | 8 +- .../api_management_update_api_version_set.py | 6 +- .../api_management_update_api_wiki.py | 6 +- ..._management_update_authorization_server.py | 6 +- .../api_management_update_backend.py | 6 +- .../api_management_update_cache.py | 6 +- .../api_management_update_diagnostic.py | 6 +- .../api_management_update_gateway.py | 6 +- ...management_update_graph_ql_api_resolver.py | 6 +- .../api_management_update_group.py | 6 +- ...api_management_update_identity_provider.py | 9 +- .../api_management_update_logger.py | 6 +- .../api_management_update_named_value.py | 6 +- ...agement_update_open_id_connect_provider.py | 6 +- ...pi_management_update_policy_restriction.py | 45 + .../api_management_update_portal_config.py | 6 +- .../api_management_update_portal_revision.py | 6 +- .../api_management_update_product.py | 6 +- .../api_management_update_product_wiki.py | 6 +- ...api_management_update_quota_counter_key.py | 6 +- ...pdate_quota_counter_key_by_quota_period.py | 6 +- ...management_update_service_disable_tls10.py | 6 +- ...gement_update_service_publisher_details.py | 6 +- ...ment_update_service_to_new_vnet_and_azs.py | 14 +- .../api_management_update_standard_gateway.py | 47 + .../api_management_update_subscription.py | 6 +- .../api_management_update_tag.py | 6 +- .../api_management_update_template.py | 9 +- .../api_management_update_tenant_access.py | 9 +- .../api_management_update_user.py | 6 +- ....py => api_management_update_workspace.py} | 14 +- .../api_management_update_workspace_api.py | 52 + ...agement_update_workspace_api_diagnostic.py | 61 + ...nagement_update_workspace_api_operation.py | 70 + ...management_update_workspace_api_release.py | 52 + ...gement_update_workspace_api_version_set.py | 52 + ...api_management_update_workspace_backend.py | 51 + ..._management_update_workspace_diagnostic.py | 60 + .../api_management_update_workspace_group.py | 46 + .../api_management_update_workspace_logger.py | 46 + ...management_update_workspace_named_value.py | 48 + ...api_management_update_workspace_product.py | 46 + ...anagement_update_workspace_subscription.py | 46 + .../api_management_update_workspace_tag.py | 46 + ...agement_user_confirmation_password_send.py | 4 +- .../api_management_user_generate_sso_url.py | 4 +- .../api_management_user_token.py | 6 +- .../api_management_validate_policies.py | 42 + ...gement_workspace_named_value_list_value.py | 44 + ...ent_workspace_subscription_list_secrets.py | 44 + ...ace_subscription_regenerate_primary_key.py | 43 + ...e_subscription_regenerate_secondary_key.py | 43 + .../generated_tests/conftest.py | 35 + .../generated_tests/test_api_management.py | 44 + ..._api_management_all_policies_operations.py | 31 + ...anagement_all_policies_operations_async.py | 32 + ...pi_management_api_diagnostic_operations.py | 202 + ...agement_api_diagnostic_operations_async.py | 203 + ...st_api_management_api_export_operations.py | 34 + ..._management_api_export_operations_async.py | 35 + ...pi_gateway_config_connection_operations.py | 81 + ...eway_config_connection_operations_async.py | 86 + ...t_api_management_api_gateway_operations.py | 127 + ...management_api_gateway_operations_async.py | 134 + ...agement_api_issue_attachment_operations.py | 102 + ...t_api_issue_attachment_operations_async.py | 103 + ...management_api_issue_comment_operations.py | 102 + ...ment_api_issue_comment_operations_async.py | 103 + ...est_api_management_api_issue_operations.py | 123 + ...i_management_api_issue_operations_async.py | 124 + ..._api_management_gateway_skus_operations.py | 31 + ...anagement_gateway_skus_operations_async.py | 32 + ...nt_api_management_operations_operations.py | 29 + ..._management_operations_operations_async.py | 30 + ...ement_api_management_service_operations.py | 398 ++ ...api_management_service_operations_async.py | 413 ++ ..._api_management_service_skus_operations.py | 31 + ...anagement_service_skus_operations_async.py | 32 + ...nagement_api_management_skus_operations.py | 29 + ...nt_api_management_skus_operations_async.py | 30 + ...pi_management_workspace_link_operations.py | 32 + ...agement_workspace_link_operations_async.py | 33 + ...i_management_workspace_links_operations.py | 31 + ...gement_workspace_links_operations_async.py | 32 + ...api_management_api_operation_operations.py | 379 ++ ...nagement_api_operation_operations_async.py | 380 ++ ...agement_api_operation_policy_operations.py | 95 + ...t_api_operation_policy_operations_async.py | 96 + .../test_api_management_api_operations.py | 177 + ...est_api_management_api_operations_async.py | 184 + ...st_api_management_api_policy_operations.py | 90 + ..._management_api_policy_operations_async.py | 91 + ...t_api_management_api_product_operations.py | 32 + ...management_api_product_operations_async.py | 33 + ...t_api_management_api_release_operations.py | 122 + ...management_api_release_operations_async.py | 123 + ..._api_management_api_revision_operations.py | 32 + ...anagement_api_revision_operations_async.py | 33 + ...st_api_management_api_schema_operations.py | 99 + ..._management_api_schema_operations_async.py | 102 + ...nagement_api_tag_description_operations.py | 90 + ...nt_api_tag_description_operations_async.py | 91 + ...i_management_api_version_set_operations.py | 115 + ...gement_api_version_set_operations_async.py | 116 + ...test_api_management_api_wiki_operations.py | 88 + ...pi_management_api_wiki_operations_async.py | 89 + ...est_api_management_api_wikis_operations.py | 32 + ...i_management_api_wikis_operations_async.py | 33 + .../test_api_management_async.py | 47 + ..._authorization_access_policy_operations.py | 87 + ...rization_access_policy_operations_async.py | 88 + ...nt_authorization_login_links_operations.py | 34 + ...horization_login_links_operations_async.py | 35 + ...api_management_authorization_operations.py | 100 + ...nagement_authorization_operations_async.py | 101 + ...ement_authorization_provider_operations.py | 82 + ...authorization_provider_operations_async.py | 83 + ...agement_authorization_server_operations.py | 157 + ...t_authorization_server_operations_async.py | 158 + .../test_api_management_backend_operations.py | 201 + ...api_management_backend_operations_async.py | 202 + .../test_api_management_cache_operations.py | 108 + ...t_api_management_cache_operations_async.py | 109 + ...t_api_management_certificate_operations.py | 102 + ...management_certificate_operations_async.py | 103 + ..._api_management_content_item_operations.py | 90 + ...anagement_content_item_operations_async.py | 91 + ..._api_management_content_type_operations.py | 79 + ...anagement_content_type_operations_async.py | 80 + ...nagement_delegation_settings_operations.py | 98 + ...nt_delegation_settings_operations_async.py | 99 + ..._management_deleted_services_operations.py | 53 + ...ement_deleted_services_operations_async.py | 56 + ...st_api_management_diagnostic_operations.py | 196 + ..._management_diagnostic_operations_async.py | 197 + ...api_management_documentation_operations.py | 100 + ...nagement_documentation_operations_async.py | 101 + ...pi_management_email_template_operations.py | 112 + ...agement_email_template_operations_async.py | 113 + ...t_api_management_gateway_api_operations.py | 74 + ...management_gateway_api_operations_async.py | 75 + ...ateway_certificate_authority_operations.py | 90 + ..._certificate_authority_operations_async.py | 91 + ...teway_hostname_configuration_operations.py | 100 + ...hostname_configuration_operations_async.py | 101 + .../test_api_management_gateway_operations.py | 194 + ...api_management_gateway_operations_async.py | 195 + ...api_management_global_schema_operations.py | 94 + ...nagement_global_schema_operations_async.py | 97 + ...gement_graph_ql_api_resolver_operations.py | 113 + ..._graph_ql_api_resolver_operations_async.py | 114 + ...graph_ql_api_resolver_policy_operations.py | 95 + ...ql_api_resolver_policy_operations_async.py | 96 + .../test_api_management_group_operations.py | 100 + ...t_api_management_group_operations_async.py | 101 + ...st_api_management_group_user_operations.py | 74 + ..._management_group_user_operations_async.py | 75 + ...management_identity_provider_operations.py | 139 + ...ment_identity_provider_operations_async.py | 140 + .../test_api_management_issue_operations.py | 44 + ...t_api_management_issue_operations_async.py | 45 + .../test_api_management_logger_operations.py | 109 + ..._api_management_logger_operations_async.py | 110 + ...t_api_management_named_value_operations.py | 141 + ...management_named_value_operations_async.py | 148 + ...pi_management_network_status_operations.py | 44 + ...agement_network_status_operations_async.py | 45 + ..._api_management_notification_operations.py | 57 + ...anagement_notification_operations_async.py | 58 + ...notification_recipient_email_operations.py | 74 + ...cation_recipient_email_operations_async.py | 75 + ..._notification_recipient_user_operations.py | 74 + ...ication_recipient_user_operations_async.py | 75 + ...ent_open_id_connect_provider_operations.py | 132 + ...en_id_connect_provider_operations_async.py | 133 + ...est_api_management_operation_operations.py | 32 + ...i_management_operation_operations_async.py | 33 + ..._management_operation_status_operations.py | 31 + ...ement_operation_status_operations_async.py | 32 + ...anagement_operations_results_operations.py | 31 + ...ent_operations_results_operations_async.py | 32 + ...twork_dependencies_endpoints_operations.py | 31 + ...dependencies_endpoints_operations_async.py | 32 + ...anagement_policy_description_operations.py | 31 + ...ent_policy_description_operations_async.py | 32 + ...i_management_policy_fragment_operations.py | 106 + ...gement_policy_fragment_operations_async.py | 109 + .../test_api_management_policy_operations.py | 85 + ..._api_management_policy_operations_async.py | 86 + ...anagement_policy_restriction_operations.py | 99 + ...ent_policy_restriction_operations_async.py | 100 + ...licy_restriction_validations_operations.py | 31 + ...estriction_validations_operations_async.py | 34 + ...api_management_portal_config_operations.py | 117 + ...nagement_portal_config_operations_async.py | 118 + ...i_management_portal_revision_operations.py | 108 + ...gement_portal_revision_operations_async.py | 113 + ...i_management_portal_settings_operations.py | 31 + ...gement_portal_settings_operations_async.py | 32 + ..._private_endpoint_connection_operations.py | 105 + ...te_endpoint_connection_operations_async.py | 110 + ..._management_product_api_link_operations.py | 75 + ...ement_product_api_link_operations_async.py | 76 + ...t_api_management_product_api_operations.py | 74 + ...management_product_api_operations_async.py | 75 + ...anagement_product_group_link_operations.py | 75 + ...ent_product_group_link_operations_async.py | 76 + ...api_management_product_group_operations.py | 74 + ...nagement_product_group_operations_async.py | 75 + .../test_api_management_product_operations.py | 131 + ...api_management_product_operations_async.py | 132 + ...pi_management_product_policy_operations.py | 90 + ...agement_product_policy_operations_async.py | 91 + ...gement_product_subscriptions_operations.py | 32 + ..._product_subscriptions_operations_async.py | 33 + ..._api_management_product_wiki_operations.py | 88 + ...anagement_product_wiki_operations_async.py | 89 + ...api_management_product_wikis_operations.py | 32 + ...nagement_product_wikis_operations_async.py | 33 + ...gement_quota_by_counter_keys_operations.py | 46 + ..._quota_by_counter_keys_operations_async.py | 47 + ...agement_quota_by_period_keys_operations.py | 48 + ...t_quota_by_period_keys_operations_async.py | 49 + .../test_api_management_region_operations.py | 31 + ..._api_management_region_operations_async.py | 32 + .../test_api_management_reports_operations.py | 124 + ...api_management_reports_operations_async.py | 125 + ..._management_sign_in_settings_operations.py | 70 + ...ement_sign_in_settings_operations_async.py | 71 + ..._management_sign_up_settings_operations.py | 82 + ...ement_sign_up_settings_operations_async.py | 83 + ..._api_management_subscription_operations.py | 157 + ...anagement_subscription_operations_async.py | 158 + ..._api_management_tag_api_link_operations.py | 75 + ...anagement_tag_api_link_operations_async.py | 76 + ...anagement_tag_operation_link_operations.py | 75 + ...ent_tag_operation_link_operations_async.py | 76 + .../test_api_management_tag_operations.py | 312 ++ ...est_api_management_tag_operations_async.py | 313 ++ ..._management_tag_product_link_operations.py | 75 + ...ement_tag_product_link_operations_async.py | 76 + ..._api_management_tag_resource_operations.py | 31 + ...anagement_tag_resource_operations_async.py | 32 + ...management_tenant_access_git_operations.py | 45 + ...ment_tenant_access_git_operations_async.py | 46 + ...api_management_tenant_access_operations.py | 126 + ...nagement_tenant_access_operations_async.py | 127 + ...agement_tenant_configuration_operations.py | 74 + ...t_tenant_configuration_operations_async.py | 81 + ...i_management_tenant_settings_operations.py | 44 + ...gement_tenant_settings_operations_async.py | 45 + ...t_user_confirmation_password_operations.py | 32 + ..._confirmation_password_operations_async.py | 33 + ...st_api_management_user_group_operations.py | 32 + ..._management_user_group_operations_async.py | 33 + ...i_management_user_identities_operations.py | 32 + ...gement_user_identities_operations_async.py | 33 + .../test_api_management_user_operations.py | 145 + ...st_api_management_user_operations_async.py | 148 + ...management_user_subscription_operations.py | 46 + ...ment_user_subscription_operations_async.py | 47 + ...ent_workspace_api_diagnostic_operations.py | 208 ++ ...rkspace_api_diagnostic_operations_async.py | 209 ++ ...agement_workspace_api_export_operations.py | 35 + ...t_workspace_api_export_operations_async.py | 36 + ...ment_workspace_api_operation_operations.py | 385 ++ ...orkspace_api_operation_operations_async.py | 386 ++ ...rkspace_api_operation_policy_operations.py | 100 + ...e_api_operation_policy_operations_async.py | 101 + ...api_management_workspace_api_operations.py | 171 + ...nagement_workspace_api_operations_async.py | 176 + ...agement_workspace_api_policy_operations.py | 95 + ...t_workspace_api_policy_operations_async.py | 96 + ...gement_workspace_api_release_operations.py | 128 + ..._workspace_api_release_operations_async.py | 129 + ...ement_workspace_api_revision_operations.py | 33 + ...workspace_api_revision_operations_async.py | 34 + ...agement_workspace_api_schema_operations.py | 104 + ...t_workspace_api_schema_operations_async.py | 107 + ...nt_workspace_api_version_set_operations.py | 121 + ...kspace_api_version_set_operations_async.py | 122 + ...management_workspace_backend_operations.py | 194 + ...ment_workspace_backend_operations_async.py | 195 + ...gement_workspace_certificate_operations.py | 108 + ..._workspace_certificate_operations_async.py | 109 + ...agement_workspace_diagnostic_operations.py | 202 + ...t_workspace_diagnostic_operations_async.py | 203 + ...ment_workspace_global_schema_operations.py | 99 + ...orkspace_global_schema_operations_async.py | 102 + ...i_management_workspace_group_operations.py | 106 + ...gement_workspace_group_operations_async.py | 107 + ...agement_workspace_group_user_operations.py | 78 + ...t_workspace_group_user_operations_async.py | 79 + ..._management_workspace_logger_operations.py | 115 + ...ement_workspace_logger_operations_async.py | 116 + ...gement_workspace_named_value_operations.py | 149 + ..._workspace_named_value_operations_async.py | 156 + ...ement_workspace_notification_operations.py | 60 + ...workspace_notification_operations_async.py | 61 + ...notification_recipient_email_operations.py | 78 + ...cation_recipient_email_operations_async.py | 79 + ..._notification_recipient_user_operations.py | 78 + ...ication_recipient_user_operations_async.py | 79 + ...est_api_management_workspace_operations.py | 100 + ...i_management_workspace_operations_async.py | 101 + ...nt_workspace_policy_fragment_operations.py | 112 + ...kspace_policy_fragment_operations_async.py | 115 + ..._management_workspace_policy_operations.py | 90 + ...ement_workspace_policy_operations_async.py | 91 + ...t_workspace_product_api_link_operations.py | 79 + ...space_product_api_link_operations_async.py | 80 + ...workspace_product_group_link_operations.py | 79 + ...ace_product_group_link_operations_async.py | 80 + ...management_workspace_product_operations.py | 125 + ...ment_workspace_product_operations_async.py | 126 + ...ent_workspace_product_policy_operations.py | 95 + ...rkspace_product_policy_operations_async.py | 96 + ...ement_workspace_subscription_operations.py | 166 + ...workspace_subscription_operations_async.py | 167 + ...ement_workspace_tag_api_link_operations.py | 79 + ...workspace_tag_api_link_operations_async.py | 80 + ...workspace_tag_operation_link_operations.py | 79 + ...ace_tag_operation_link_operations_async.py | 80 + ...api_management_workspace_tag_operations.py | 106 + ...nagement_workspace_tag_operations_async.py | 107 + ...t_workspace_tag_product_link_operations.py | 79 + ...space_tag_product_link_operations_async.py | 80 + .../azure-mgmt-apimanagement/setup.py | 1 + 1244 files changed, 110367 insertions(+), 7041 deletions(-) create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_all_policies_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_config_connection_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_gateway_skus_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_links_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_status_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operations_results_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_validations_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operation_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_product_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_export_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_release_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_revision_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_version_set_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_backend_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_certificate_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_global_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_logger_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_named_value_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_email_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_fragment_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_group_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_subscription_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operation_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_product_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_all_policies_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_config_connection_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_gateway_skus_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_links_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_status_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operations_results_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_validations_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operation_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_product_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_export_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_release_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_revision_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_version_set_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_backend_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_certificate_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_global_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_logger_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_named_value_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_email_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_fragment_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_group_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_subscription_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operation_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_product_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_all_policies.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_config_connection.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_grpc_api.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_odata_api.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy_restriction.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_group_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_skuv2_service.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_developer_portal.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_without_legacy_configuration_api.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_standard_gateway.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_operation_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_product_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_ai_logger.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_operation.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_operation_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_release.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_schema.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_version_set.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_backend_proxy_backend.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_backend_service_fabric.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_certificate.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_certificate_with_key_vault.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_eh_logger.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group_external.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group_user.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_named_value.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_named_value_with_key_vault.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification_recipient_email.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification_recipient_user.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy_fragment.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy_non_xml_encoded.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_premium_gateway.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_group_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_schema.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_subscription.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_operation_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_product_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_config_connection.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy_restriction.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_group_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_operation_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_product_link.py rename sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/{api_management_delete_documentation.py => api_management_delete_workspace.py} (83%) create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_operation.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_operation_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_release.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_schema.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_version_set.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_backend.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_certificate.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_group.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_group_user.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_logger.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_named_value.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_notification_recipient_email.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_notification_recipient_user.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_policy_fragment.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_group_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_schema.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_subscription.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_operation_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_product_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_delete_gateway.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_get_gateway.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_invalidate_debug_credentials.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_debug_credentials.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_trace.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_config_connection.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_operation_result.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_operation_status.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_restriction.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_group_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_api.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_geo.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_operation.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_product.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_request.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_subscription.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_time.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_user.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_operation_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_product_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_contract.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_export_in_open_api2dot0.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_export_in_open_api3dot0.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_operation.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_operation_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_release.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_revision.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_schema.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_version_set.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_backend.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_certificate.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_certificate_with_key_vault.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_group.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_logger.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_named_value.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_named_value_with_key_vault.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_notification.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy_fragment.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy_fragment_format.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_group_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_schema.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_subscription.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_api_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_operation_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_product_link.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy_restriction.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_operation.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_operation_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_release.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_schema.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_version_set.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_backend.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_certificate.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_group.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_group_user.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_logger.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_named_value.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_notification_recipient_email.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_notification_recipient_user.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_policy_fragment.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_product.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_product_policy.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_schema.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_subscription.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_tag.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_config_connection.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways_by_subscription.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways_by_subscription_and_resource_group.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_restrictions.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_api_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_group_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_gateways.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_api_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_operation_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_product_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_diagnostics.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_operation_policies.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_policies.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_releases.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_revisions.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_schemas.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_version_sets.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_apis.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_backends.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_certificates.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_diagnostics.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_group_users.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_groups.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_loggers.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_named_values.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notification_recipient_emails.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notification_recipient_users.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notifications.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policies.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policy_fragment_references.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policy_fragments.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_api_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_group_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_policies.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_products.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_schemas.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_subscriptions.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_api_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_operation_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_product_links.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tags.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspaces.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_workspace_certificate.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_workspace_named_value.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_policy_restriction.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_standard_gateway.py rename sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/{api_management_update_documentation.py => api_management_update_workspace.py} (77%) create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_operation.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_release.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_version_set.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_backend.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_diagnostic.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_group.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_logger.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_named_value.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_product.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_subscription.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_tag.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_validate_policies.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_named_value_list_value.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_list_secrets.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_regenerate_primary_key.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_regenerate_secondary_key.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/conftest.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_all_policies_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_all_policies_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_operations_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_operations_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_skus_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_skus_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_skus_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_skus_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_links_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_links_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_product_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_product_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wikis_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wikis_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_provider_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_provider_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_server_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_server_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_backend_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_backend_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_identity_provider_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_identity_provider_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_network_status_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_network_status_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_user_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_open_id_connect_provider_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_open_id_connect_provider_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_status_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_status_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operations_results_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operations_results_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_outbound_network_dependencies_endpoints_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_outbound_network_dependencies_endpoints_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_description_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_description_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_fragment_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_fragment_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_private_endpoint_connection_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_private_endpoint_connection_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wiki_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wiki_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wikis_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wikis_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_counter_keys_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_counter_keys_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_period_keys_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_period_keys_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_region_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_region_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_reports_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_reports_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_in_settings_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_in_settings_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_up_settings_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_up_settings_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_subscription_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_subscription_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_git_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_git_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_configuration_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_configuration_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_group_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_identities_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_identities_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_user_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_subscription_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_subscription_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations_async.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations_async.py diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json index e4d9ef0f2597..60d9338b0ba5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json +++ b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json @@ -1,11 +1,11 @@ { - "commit": "44d7a32482656b3a79a2fa11ac27c981f8e0e3cd", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "commit": "aa158e50ea4096d229c557790cb70cf63d7c748a", + "repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.13.7", + "@autorest/python@6.19.0", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/apimanagement/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --tag=package-2022-08 --use=@autorest/python@6.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/apimanagement/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/apimanagement/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py index b27dedf560d2..bc7b3a9faaee 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -18,16 +19,22 @@ from ._configuration import ApiManagementClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( + AllPoliciesOperations, ApiDiagnosticOperations, ApiExportOperations, + ApiGatewayConfigConnectionOperations, + ApiGatewayOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, ApiManagementClientOperationsMixin, + ApiManagementGatewaySkusOperations, ApiManagementOperationsOperations, ApiManagementServiceOperations, ApiManagementServiceSkusOperations, ApiManagementSkusOperations, + ApiManagementWorkspaceLinkOperations, + ApiManagementWorkspaceLinksOperations, ApiOperationOperations, ApiOperationPolicyOperations, ApiOperations, @@ -74,15 +81,21 @@ NotificationRecipientUserOperations, OpenIdConnectProviderOperations, OperationOperations, + OperationStatusOperations, + OperationsResultsOperations, OutboundNetworkDependenciesEndpointsOperations, PolicyDescriptionOperations, PolicyFragmentOperations, PolicyOperations, + PolicyRestrictionOperations, + PolicyRestrictionValidationsOperations, PortalConfigOperations, PortalRevisionOperations, PortalSettingsOperations, PrivateEndpointConnectionOperations, + ProductApiLinkOperations, ProductApiOperations, + ProductGroupLinkOperations, ProductGroupOperations, ProductOperations, ProductPolicyOperations, @@ -96,7 +109,10 @@ SignInSettingsOperations, SignUpSettingsOperations, SubscriptionOperations, + TagApiLinkOperations, + TagOperationLinkOperations, TagOperations, + TagProductLinkOperations, TagResourceOperations, TenantAccessGitOperations, TenantAccessOperations, @@ -107,6 +123,39 @@ UserIdentitiesOperations, UserOperations, UserSubscriptionOperations, + WorkspaceApiDiagnosticOperations, + WorkspaceApiExportOperations, + WorkspaceApiOperationOperations, + WorkspaceApiOperationPolicyOperations, + WorkspaceApiOperations, + WorkspaceApiPolicyOperations, + WorkspaceApiReleaseOperations, + WorkspaceApiRevisionOperations, + WorkspaceApiSchemaOperations, + WorkspaceApiVersionSetOperations, + WorkspaceBackendOperations, + WorkspaceCertificateOperations, + WorkspaceDiagnosticOperations, + WorkspaceGlobalSchemaOperations, + WorkspaceGroupOperations, + WorkspaceGroupUserOperations, + WorkspaceLoggerOperations, + WorkspaceNamedValueOperations, + WorkspaceNotificationOperations, + WorkspaceNotificationRecipientEmailOperations, + WorkspaceNotificationRecipientUserOperations, + WorkspaceOperations, + WorkspacePolicyFragmentOperations, + WorkspacePolicyOperations, + WorkspaceProductApiLinkOperations, + WorkspaceProductGroupLinkOperations, + WorkspaceProductOperations, + WorkspaceProductPolicyOperations, + WorkspaceSubscriptionOperations, + WorkspaceTagApiLinkOperations, + WorkspaceTagOperationLinkOperations, + WorkspaceTagOperations, + WorkspaceTagProductLinkOperations, ) if TYPE_CHECKING: @@ -119,6 +168,13 @@ class ApiManagementClient( ): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ApiManagement Client. + :ivar all_policies: AllPoliciesOperations operations + :vartype all_policies: azure.mgmt.apimanagement.operations.AllPoliciesOperations + :ivar api_gateway: ApiGatewayOperations operations + :vartype api_gateway: azure.mgmt.apimanagement.operations.ApiGatewayOperations + :ivar api_management_gateway_skus: ApiManagementGatewaySkusOperations operations + :vartype api_management_gateway_skus: + azure.mgmt.apimanagement.operations.ApiManagementGatewaySkusOperations :ivar api: ApiOperations operations :vartype api: azure.mgmt.apimanagement.operations.ApiOperations :ivar api_revision: ApiRevisionOperations operations @@ -163,9 +219,6 @@ class ApiManagementClient( :vartype api_export: azure.mgmt.apimanagement.operations.ApiExportOperations :ivar api_version_set: ApiVersionSetOperations operations :vartype api_version_set: azure.mgmt.apimanagement.operations.ApiVersionSetOperations - :ivar authorization_server: AuthorizationServerOperations operations - :vartype authorization_server: - azure.mgmt.apimanagement.operations.AuthorizationServerOperations :ivar authorization_provider: AuthorizationProviderOperations operations :vartype authorization_provider: azure.mgmt.apimanagement.operations.AuthorizationProviderOperations @@ -177,6 +230,9 @@ class ApiManagementClient( :ivar authorization_access_policy: AuthorizationAccessPolicyOperations operations :vartype authorization_access_policy: azure.mgmt.apimanagement.operations.AuthorizationAccessPolicyOperations + :ivar authorization_server: AuthorizationServerOperations operations + :vartype authorization_server: + azure.mgmt.apimanagement.operations.AuthorizationServerOperations :ivar backend: BackendOperations operations :vartype backend: azure.mgmt.apimanagement.operations.BackendOperations :ivar cache: CacheOperations operations @@ -200,6 +256,8 @@ class ApiManagementClient( azure.mgmt.apimanagement.operations.ApiManagementServiceOperations :ivar diagnostic: DiagnosticOperations operations :vartype diagnostic: azure.mgmt.apimanagement.operations.DiagnosticOperations + :ivar documentation: DocumentationOperations operations + :vartype documentation: azure.mgmt.apimanagement.operations.DocumentationOperations :ivar email_template: EmailTemplateOperations operations :vartype email_template: azure.mgmt.apimanagement.operations.EmailTemplateOperations :ivar gateway: GatewayOperations operations @@ -212,6 +270,9 @@ class ApiManagementClient( :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations :vartype gateway_certificate_authority: azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations + :ivar api_gateway_config_connection: ApiGatewayConfigConnectionOperations operations + :vartype api_gateway_config_connection: + azure.mgmt.apimanagement.operations.ApiGatewayConfigConnectionOperations :ivar group: GroupOperations operations :vartype group: azure.mgmt.apimanagement.operations.GroupOperations :ivar group_user: GroupUserOperations operations @@ -247,6 +308,11 @@ class ApiManagementClient( :vartype policy_description: azure.mgmt.apimanagement.operations.PolicyDescriptionOperations :ivar policy_fragment: PolicyFragmentOperations operations :vartype policy_fragment: azure.mgmt.apimanagement.operations.PolicyFragmentOperations + :ivar policy_restriction: PolicyRestrictionOperations operations + :vartype policy_restriction: azure.mgmt.apimanagement.operations.PolicyRestrictionOperations + :ivar policy_restriction_validations: PolicyRestrictionValidationsOperations operations + :vartype policy_restriction_validations: + azure.mgmt.apimanagement.operations.PolicyRestrictionValidationsOperations :ivar portal_config: PortalConfigOperations operations :vartype portal_config: azure.mgmt.apimanagement.operations.PortalConfigOperations :ivar portal_revision: PortalRevisionOperations operations @@ -277,6 +343,10 @@ class ApiManagementClient( :vartype product_wiki: azure.mgmt.apimanagement.operations.ProductWikiOperations :ivar product_wikis: ProductWikisOperations operations :vartype product_wikis: azure.mgmt.apimanagement.operations.ProductWikisOperations + :ivar product_api_link: ProductApiLinkOperations operations + :vartype product_api_link: azure.mgmt.apimanagement.operations.ProductApiLinkOperations + :ivar product_group_link: ProductGroupLinkOperations operations + :vartype product_group_link: azure.mgmt.apimanagement.operations.ProductGroupLinkOperations :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations :vartype quota_by_counter_keys: azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations @@ -296,6 +366,12 @@ class ApiManagementClient( :vartype subscription: azure.mgmt.apimanagement.operations.SubscriptionOperations :ivar tag_resource: TagResourceOperations operations :vartype tag_resource: azure.mgmt.apimanagement.operations.TagResourceOperations + :ivar tag_api_link: TagApiLinkOperations operations + :vartype tag_api_link: azure.mgmt.apimanagement.operations.TagApiLinkOperations + :ivar tag_operation_link: TagOperationLinkOperations operations + :vartype tag_operation_link: azure.mgmt.apimanagement.operations.TagOperationLinkOperations + :ivar tag_product_link: TagProductLinkOperations operations + :vartype tag_product_link: azure.mgmt.apimanagement.operations.TagProductLinkOperations :ivar tenant_access: TenantAccessOperations operations :vartype tenant_access: azure.mgmt.apimanagement.operations.TenantAccessOperations :ivar tenant_access_git: TenantAccessGitOperations operations @@ -314,15 +390,112 @@ class ApiManagementClient( :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: azure.mgmt.apimanagement.operations.UserConfirmationPasswordOperations - :ivar documentation: DocumentationOperations operations - :vartype documentation: azure.mgmt.apimanagement.operations.DocumentationOperations + :ivar workspace_backend: WorkspaceBackendOperations operations + :vartype workspace_backend: azure.mgmt.apimanagement.operations.WorkspaceBackendOperations + :ivar workspace_certificate: WorkspaceCertificateOperations operations + :vartype workspace_certificate: + azure.mgmt.apimanagement.operations.WorkspaceCertificateOperations + :ivar workspace_diagnostic: WorkspaceDiagnosticOperations operations + :vartype workspace_diagnostic: + azure.mgmt.apimanagement.operations.WorkspaceDiagnosticOperations + :ivar workspace_api_diagnostic: WorkspaceApiDiagnosticOperations operations + :vartype workspace_api_diagnostic: + azure.mgmt.apimanagement.operations.WorkspaceApiDiagnosticOperations + :ivar workspace_logger: WorkspaceLoggerOperations operations + :vartype workspace_logger: azure.mgmt.apimanagement.operations.WorkspaceLoggerOperations + :ivar api_management_workspace_links: ApiManagementWorkspaceLinksOperations operations + :vartype api_management_workspace_links: + azure.mgmt.apimanagement.operations.ApiManagementWorkspaceLinksOperations + :ivar api_management_workspace_link: ApiManagementWorkspaceLinkOperations operations + :vartype api_management_workspace_link: + azure.mgmt.apimanagement.operations.ApiManagementWorkspaceLinkOperations + :ivar workspace: WorkspaceOperations operations + :vartype workspace: azure.mgmt.apimanagement.operations.WorkspaceOperations + :ivar workspace_policy: WorkspacePolicyOperations operations + :vartype workspace_policy: azure.mgmt.apimanagement.operations.WorkspacePolicyOperations + :ivar workspace_named_value: WorkspaceNamedValueOperations operations + :vartype workspace_named_value: + azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations + :ivar workspace_global_schema: WorkspaceGlobalSchemaOperations operations + :vartype workspace_global_schema: + azure.mgmt.apimanagement.operations.WorkspaceGlobalSchemaOperations + :ivar workspace_notification: WorkspaceNotificationOperations operations + :vartype workspace_notification: + azure.mgmt.apimanagement.operations.WorkspaceNotificationOperations + :ivar workspace_notification_recipient_user: WorkspaceNotificationRecipientUserOperations + operations + :vartype workspace_notification_recipient_user: + azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientUserOperations + :ivar workspace_notification_recipient_email: WorkspaceNotificationRecipientEmailOperations + operations + :vartype workspace_notification_recipient_email: + azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientEmailOperations + :ivar workspace_policy_fragment: WorkspacePolicyFragmentOperations operations + :vartype workspace_policy_fragment: + azure.mgmt.apimanagement.operations.WorkspacePolicyFragmentOperations + :ivar workspace_group: WorkspaceGroupOperations operations + :vartype workspace_group: azure.mgmt.apimanagement.operations.WorkspaceGroupOperations + :ivar workspace_group_user: WorkspaceGroupUserOperations operations + :vartype workspace_group_user: azure.mgmt.apimanagement.operations.WorkspaceGroupUserOperations + :ivar workspace_subscription: WorkspaceSubscriptionOperations operations + :vartype workspace_subscription: + azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations + :ivar workspace_api_version_set: WorkspaceApiVersionSetOperations operations + :vartype workspace_api_version_set: + azure.mgmt.apimanagement.operations.WorkspaceApiVersionSetOperations + :ivar workspace_api: WorkspaceApiOperations operations + :vartype workspace_api: azure.mgmt.apimanagement.operations.WorkspaceApiOperations + :ivar workspace_api_revision: WorkspaceApiRevisionOperations operations + :vartype workspace_api_revision: + azure.mgmt.apimanagement.operations.WorkspaceApiRevisionOperations + :ivar workspace_api_release: WorkspaceApiReleaseOperations operations + :vartype workspace_api_release: + azure.mgmt.apimanagement.operations.WorkspaceApiReleaseOperations + :ivar workspace_api_operation: WorkspaceApiOperationOperations operations + :vartype workspace_api_operation: + azure.mgmt.apimanagement.operations.WorkspaceApiOperationOperations + :ivar workspace_api_operation_policy: WorkspaceApiOperationPolicyOperations operations + :vartype workspace_api_operation_policy: + azure.mgmt.apimanagement.operations.WorkspaceApiOperationPolicyOperations + :ivar workspace_api_policy: WorkspaceApiPolicyOperations operations + :vartype workspace_api_policy: azure.mgmt.apimanagement.operations.WorkspaceApiPolicyOperations + :ivar workspace_api_schema: WorkspaceApiSchemaOperations operations + :vartype workspace_api_schema: azure.mgmt.apimanagement.operations.WorkspaceApiSchemaOperations + :ivar workspace_product: WorkspaceProductOperations operations + :vartype workspace_product: azure.mgmt.apimanagement.operations.WorkspaceProductOperations + :ivar workspace_product_api_link: WorkspaceProductApiLinkOperations operations + :vartype workspace_product_api_link: + azure.mgmt.apimanagement.operations.WorkspaceProductApiLinkOperations + :ivar workspace_product_group_link: WorkspaceProductGroupLinkOperations operations + :vartype workspace_product_group_link: + azure.mgmt.apimanagement.operations.WorkspaceProductGroupLinkOperations + :ivar workspace_product_policy: WorkspaceProductPolicyOperations operations + :vartype workspace_product_policy: + azure.mgmt.apimanagement.operations.WorkspaceProductPolicyOperations + :ivar workspace_tag: WorkspaceTagOperations operations + :vartype workspace_tag: azure.mgmt.apimanagement.operations.WorkspaceTagOperations + :ivar workspace_tag_api_link: WorkspaceTagApiLinkOperations operations + :vartype workspace_tag_api_link: + azure.mgmt.apimanagement.operations.WorkspaceTagApiLinkOperations + :ivar workspace_tag_operation_link: WorkspaceTagOperationLinkOperations operations + :vartype workspace_tag_operation_link: + azure.mgmt.apimanagement.operations.WorkspaceTagOperationLinkOperations + :ivar workspace_tag_product_link: WorkspaceTagProductLinkOperations operations + :vartype workspace_tag_product_link: + azure.mgmt.apimanagement.operations.WorkspaceTagProductLinkOperations + :ivar workspace_api_export: WorkspaceApiExportOperations operations + :vartype workspace_api_export: azure.mgmt.apimanagement.operations.WorkspaceApiExportOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: azure.mgmt.apimanagement.operations.OperationStatusOperations + :ivar operations_results: OperationsResultsOperations operations + :vartype operations_results: azure.mgmt.apimanagement.operations.OperationsResultsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -363,6 +536,11 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False + self.all_policies = AllPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_gateway = ApiGatewayOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_management_gateway_skus = ApiManagementGatewaySkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.api = ApiOperations(self._client, self._config, self._serialize, self._deserialize) self.api_revision = ApiRevisionOperations(self._client, self._config, self._serialize, self._deserialize) self.api_release = ApiReleaseOperations(self._client, self._config, self._serialize, self._deserialize) @@ -396,9 +574,6 @@ def __init__( self.api_wikis = ApiWikisOperations(self._client, self._config, self._serialize, self._deserialize) self.api_export = ApiExportOperations(self._client, self._config, self._serialize, self._deserialize) self.api_version_set = ApiVersionSetOperations(self._client, self._config, self._serialize, self._deserialize) - self.authorization_server = AuthorizationServerOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.authorization_provider = AuthorizationProviderOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -409,6 +584,9 @@ def __init__( self.authorization_access_policy = AuthorizationAccessPolicyOperations( self._client, self._config, self._serialize, self._deserialize ) + self.authorization_server = AuthorizationServerOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.backend = BackendOperations(self._client, self._config, self._serialize, self._deserialize) self.cache = CacheOperations(self._client, self._config, self._serialize, self._deserialize) self.certificate = CertificateOperations(self._client, self._config, self._serialize, self._deserialize) @@ -427,6 +605,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.diagnostic = DiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) + self.documentation = DocumentationOperations(self._client, self._config, self._serialize, self._deserialize) self.email_template = EmailTemplateOperations(self._client, self._config, self._serialize, self._deserialize) self.gateway = GatewayOperations(self._client, self._config, self._serialize, self._deserialize) self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( @@ -436,6 +615,9 @@ def __init__( self.gateway_certificate_authority = GatewayCertificateAuthorityOperations( self._client, self._config, self._serialize, self._deserialize ) + self.api_gateway_config_connection = ApiGatewayConfigConnectionOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.group = GroupOperations(self._client, self._config, self._serialize, self._deserialize) self.group_user = GroupUserOperations(self._client, self._config, self._serialize, self._deserialize) self.identity_provider = IdentityProviderOperations( @@ -463,6 +645,12 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.policy_fragment = PolicyFragmentOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_restriction = PolicyRestrictionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_restriction_validations = PolicyRestrictionValidationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.portal_config = PortalConfigOperations(self._client, self._config, self._serialize, self._deserialize) self.portal_revision = PortalRevisionOperations(self._client, self._config, self._serialize, self._deserialize) self.portal_settings = PortalSettingsOperations(self._client, self._config, self._serialize, self._deserialize) @@ -483,6 +671,10 @@ def __init__( self.product_policy = ProductPolicyOperations(self._client, self._config, self._serialize, self._deserialize) self.product_wiki = ProductWikiOperations(self._client, self._config, self._serialize, self._deserialize) self.product_wikis = ProductWikisOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_api_link = ProductApiLinkOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_group_link = ProductGroupLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.quota_by_counter_keys = QuotaByCounterKeysOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -498,6 +690,11 @@ def __init__( ) self.subscription = SubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) self.tag_resource = TagResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.tag_api_link = TagApiLinkOperations(self._client, self._config, self._serialize, self._deserialize) + self.tag_operation_link = TagOperationLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tag_product_link = TagProductLinkOperations(self._client, self._config, self._serialize, self._deserialize) self.tenant_access = TenantAccessOperations(self._client, self._config, self._serialize, self._deserialize) self.tenant_access_git = TenantAccessGitOperations( self._client, self._config, self._serialize, self._deserialize @@ -514,7 +711,109 @@ def __init__( self.user_confirmation_password = UserConfirmationPasswordOperations( self._client, self._config, self._serialize, self._deserialize ) - self.documentation = DocumentationOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_backend = WorkspaceBackendOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_certificate = WorkspaceCertificateOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_diagnostic = WorkspaceDiagnosticOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_diagnostic = WorkspaceApiDiagnosticOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_logger = WorkspaceLoggerOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_workspace_links = ApiManagementWorkspaceLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_workspace_link = ApiManagementWorkspaceLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace = WorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_policy = WorkspacePolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_named_value = WorkspaceNamedValueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_global_schema = WorkspaceGlobalSchemaOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_notification = WorkspaceNotificationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_notification_recipient_user = WorkspaceNotificationRecipientUserOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_notification_recipient_email = WorkspaceNotificationRecipientEmailOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_policy_fragment = WorkspacePolicyFragmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_group = WorkspaceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_group_user = WorkspaceGroupUserOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_subscription = WorkspaceSubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_version_set = WorkspaceApiVersionSetOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api = WorkspaceApiOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_api_revision = WorkspaceApiRevisionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_release = WorkspaceApiReleaseOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_operation = WorkspaceApiOperationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_operation_policy = WorkspaceApiOperationPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_policy = WorkspaceApiPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_schema = WorkspaceApiSchemaOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_product = WorkspaceProductOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_product_api_link = WorkspaceProductApiLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_product_group_link = WorkspaceProductGroupLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_product_policy = WorkspaceProductPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_tag = WorkspaceTagOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_tag_api_link = WorkspaceTagApiLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_tag_operation_link = WorkspaceTagOperationLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_tag_product_link = WorkspaceTagProductLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_export = WorkspaceApiExportOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations_results = OperationsResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. @@ -541,7 +840,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "ApiManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py index 751176a90d42..ed6d6ecf5cf4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py @@ -26,15 +26,15 @@ class ApiManagementClientConfiguration: # pylint: disable=too-many-instance-att :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-08-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-08-01") + api_version: str = kwargs.pop("api_version", "2024-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py index 2f781d740827..8139854b97bb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py @@ -144,6 +144,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -1441,7 +1443,7 @@ def _deserialize(self, target_obj, data): elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py index ffe974b35563..45ee70ef5710 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py @@ -8,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import ApiManagementClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ from ._serialization import Deserializer, Serializer -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - class ApiManagementClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py index 8c472f3c2199..dab23fec502f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -18,16 +19,22 @@ from .._serialization import Deserializer, Serializer from ._configuration import ApiManagementClientConfiguration from .operations import ( + AllPoliciesOperations, ApiDiagnosticOperations, ApiExportOperations, + ApiGatewayConfigConnectionOperations, + ApiGatewayOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, ApiManagementClientOperationsMixin, + ApiManagementGatewaySkusOperations, ApiManagementOperationsOperations, ApiManagementServiceOperations, ApiManagementServiceSkusOperations, ApiManagementSkusOperations, + ApiManagementWorkspaceLinkOperations, + ApiManagementWorkspaceLinksOperations, ApiOperationOperations, ApiOperationPolicyOperations, ApiOperations, @@ -74,15 +81,21 @@ NotificationRecipientUserOperations, OpenIdConnectProviderOperations, OperationOperations, + OperationStatusOperations, + OperationsResultsOperations, OutboundNetworkDependenciesEndpointsOperations, PolicyDescriptionOperations, PolicyFragmentOperations, PolicyOperations, + PolicyRestrictionOperations, + PolicyRestrictionValidationsOperations, PortalConfigOperations, PortalRevisionOperations, PortalSettingsOperations, PrivateEndpointConnectionOperations, + ProductApiLinkOperations, ProductApiOperations, + ProductGroupLinkOperations, ProductGroupOperations, ProductOperations, ProductPolicyOperations, @@ -96,7 +109,10 @@ SignInSettingsOperations, SignUpSettingsOperations, SubscriptionOperations, + TagApiLinkOperations, + TagOperationLinkOperations, TagOperations, + TagProductLinkOperations, TagResourceOperations, TenantAccessGitOperations, TenantAccessOperations, @@ -107,6 +123,39 @@ UserIdentitiesOperations, UserOperations, UserSubscriptionOperations, + WorkspaceApiDiagnosticOperations, + WorkspaceApiExportOperations, + WorkspaceApiOperationOperations, + WorkspaceApiOperationPolicyOperations, + WorkspaceApiOperations, + WorkspaceApiPolicyOperations, + WorkspaceApiReleaseOperations, + WorkspaceApiRevisionOperations, + WorkspaceApiSchemaOperations, + WorkspaceApiVersionSetOperations, + WorkspaceBackendOperations, + WorkspaceCertificateOperations, + WorkspaceDiagnosticOperations, + WorkspaceGlobalSchemaOperations, + WorkspaceGroupOperations, + WorkspaceGroupUserOperations, + WorkspaceLoggerOperations, + WorkspaceNamedValueOperations, + WorkspaceNotificationOperations, + WorkspaceNotificationRecipientEmailOperations, + WorkspaceNotificationRecipientUserOperations, + WorkspaceOperations, + WorkspacePolicyFragmentOperations, + WorkspacePolicyOperations, + WorkspaceProductApiLinkOperations, + WorkspaceProductGroupLinkOperations, + WorkspaceProductOperations, + WorkspaceProductPolicyOperations, + WorkspaceSubscriptionOperations, + WorkspaceTagApiLinkOperations, + WorkspaceTagOperationLinkOperations, + WorkspaceTagOperations, + WorkspaceTagProductLinkOperations, ) if TYPE_CHECKING: @@ -119,6 +168,13 @@ class ApiManagementClient( ): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ApiManagement Client. + :ivar all_policies: AllPoliciesOperations operations + :vartype all_policies: azure.mgmt.apimanagement.aio.operations.AllPoliciesOperations + :ivar api_gateway: ApiGatewayOperations operations + :vartype api_gateway: azure.mgmt.apimanagement.aio.operations.ApiGatewayOperations + :ivar api_management_gateway_skus: ApiManagementGatewaySkusOperations operations + :vartype api_management_gateway_skus: + azure.mgmt.apimanagement.aio.operations.ApiManagementGatewaySkusOperations :ivar api: ApiOperations operations :vartype api: azure.mgmt.apimanagement.aio.operations.ApiOperations :ivar api_revision: ApiRevisionOperations operations @@ -166,9 +222,6 @@ class ApiManagementClient( :vartype api_export: azure.mgmt.apimanagement.aio.operations.ApiExportOperations :ivar api_version_set: ApiVersionSetOperations operations :vartype api_version_set: azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations - :ivar authorization_server: AuthorizationServerOperations operations - :vartype authorization_server: - azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations :ivar authorization_provider: AuthorizationProviderOperations operations :vartype authorization_provider: azure.mgmt.apimanagement.aio.operations.AuthorizationProviderOperations @@ -180,6 +233,9 @@ class ApiManagementClient( :ivar authorization_access_policy: AuthorizationAccessPolicyOperations operations :vartype authorization_access_policy: azure.mgmt.apimanagement.aio.operations.AuthorizationAccessPolicyOperations + :ivar authorization_server: AuthorizationServerOperations operations + :vartype authorization_server: + azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations :ivar backend: BackendOperations operations :vartype backend: azure.mgmt.apimanagement.aio.operations.BackendOperations :ivar cache: CacheOperations operations @@ -203,6 +259,8 @@ class ApiManagementClient( azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations :ivar diagnostic: DiagnosticOperations operations :vartype diagnostic: azure.mgmt.apimanagement.aio.operations.DiagnosticOperations + :ivar documentation: DocumentationOperations operations + :vartype documentation: azure.mgmt.apimanagement.aio.operations.DocumentationOperations :ivar email_template: EmailTemplateOperations operations :vartype email_template: azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations :ivar gateway: GatewayOperations operations @@ -215,6 +273,9 @@ class ApiManagementClient( :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations :vartype gateway_certificate_authority: azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations + :ivar api_gateway_config_connection: ApiGatewayConfigConnectionOperations operations + :vartype api_gateway_config_connection: + azure.mgmt.apimanagement.aio.operations.ApiGatewayConfigConnectionOperations :ivar group: GroupOperations operations :vartype group: azure.mgmt.apimanagement.aio.operations.GroupOperations :ivar group_user: GroupUserOperations operations @@ -251,6 +312,12 @@ class ApiManagementClient( azure.mgmt.apimanagement.aio.operations.PolicyDescriptionOperations :ivar policy_fragment: PolicyFragmentOperations operations :vartype policy_fragment: azure.mgmt.apimanagement.aio.operations.PolicyFragmentOperations + :ivar policy_restriction: PolicyRestrictionOperations operations + :vartype policy_restriction: + azure.mgmt.apimanagement.aio.operations.PolicyRestrictionOperations + :ivar policy_restriction_validations: PolicyRestrictionValidationsOperations operations + :vartype policy_restriction_validations: + azure.mgmt.apimanagement.aio.operations.PolicyRestrictionValidationsOperations :ivar portal_config: PortalConfigOperations operations :vartype portal_config: azure.mgmt.apimanagement.aio.operations.PortalConfigOperations :ivar portal_revision: PortalRevisionOperations operations @@ -282,6 +349,10 @@ class ApiManagementClient( :vartype product_wiki: azure.mgmt.apimanagement.aio.operations.ProductWikiOperations :ivar product_wikis: ProductWikisOperations operations :vartype product_wikis: azure.mgmt.apimanagement.aio.operations.ProductWikisOperations + :ivar product_api_link: ProductApiLinkOperations operations + :vartype product_api_link: azure.mgmt.apimanagement.aio.operations.ProductApiLinkOperations + :ivar product_group_link: ProductGroupLinkOperations operations + :vartype product_group_link: azure.mgmt.apimanagement.aio.operations.ProductGroupLinkOperations :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations :vartype quota_by_counter_keys: azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations @@ -303,6 +374,12 @@ class ApiManagementClient( :vartype subscription: azure.mgmt.apimanagement.aio.operations.SubscriptionOperations :ivar tag_resource: TagResourceOperations operations :vartype tag_resource: azure.mgmt.apimanagement.aio.operations.TagResourceOperations + :ivar tag_api_link: TagApiLinkOperations operations + :vartype tag_api_link: azure.mgmt.apimanagement.aio.operations.TagApiLinkOperations + :ivar tag_operation_link: TagOperationLinkOperations operations + :vartype tag_operation_link: azure.mgmt.apimanagement.aio.operations.TagOperationLinkOperations + :ivar tag_product_link: TagProductLinkOperations operations + :vartype tag_product_link: azure.mgmt.apimanagement.aio.operations.TagProductLinkOperations :ivar tenant_access: TenantAccessOperations operations :vartype tenant_access: azure.mgmt.apimanagement.aio.operations.TenantAccessOperations :ivar tenant_access_git: TenantAccessGitOperations operations @@ -321,15 +398,117 @@ class ApiManagementClient( :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: azure.mgmt.apimanagement.aio.operations.UserConfirmationPasswordOperations - :ivar documentation: DocumentationOperations operations - :vartype documentation: azure.mgmt.apimanagement.aio.operations.DocumentationOperations + :ivar workspace_backend: WorkspaceBackendOperations operations + :vartype workspace_backend: azure.mgmt.apimanagement.aio.operations.WorkspaceBackendOperations + :ivar workspace_certificate: WorkspaceCertificateOperations operations + :vartype workspace_certificate: + azure.mgmt.apimanagement.aio.operations.WorkspaceCertificateOperations + :ivar workspace_diagnostic: WorkspaceDiagnosticOperations operations + :vartype workspace_diagnostic: + azure.mgmt.apimanagement.aio.operations.WorkspaceDiagnosticOperations + :ivar workspace_api_diagnostic: WorkspaceApiDiagnosticOperations operations + :vartype workspace_api_diagnostic: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiDiagnosticOperations + :ivar workspace_logger: WorkspaceLoggerOperations operations + :vartype workspace_logger: azure.mgmt.apimanagement.aio.operations.WorkspaceLoggerOperations + :ivar api_management_workspace_links: ApiManagementWorkspaceLinksOperations operations + :vartype api_management_workspace_links: + azure.mgmt.apimanagement.aio.operations.ApiManagementWorkspaceLinksOperations + :ivar api_management_workspace_link: ApiManagementWorkspaceLinkOperations operations + :vartype api_management_workspace_link: + azure.mgmt.apimanagement.aio.operations.ApiManagementWorkspaceLinkOperations + :ivar workspace: WorkspaceOperations operations + :vartype workspace: azure.mgmt.apimanagement.aio.operations.WorkspaceOperations + :ivar workspace_policy: WorkspacePolicyOperations operations + :vartype workspace_policy: azure.mgmt.apimanagement.aio.operations.WorkspacePolicyOperations + :ivar workspace_named_value: WorkspaceNamedValueOperations operations + :vartype workspace_named_value: + azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations + :ivar workspace_global_schema: WorkspaceGlobalSchemaOperations operations + :vartype workspace_global_schema: + azure.mgmt.apimanagement.aio.operations.WorkspaceGlobalSchemaOperations + :ivar workspace_notification: WorkspaceNotificationOperations operations + :vartype workspace_notification: + azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationOperations + :ivar workspace_notification_recipient_user: WorkspaceNotificationRecipientUserOperations + operations + :vartype workspace_notification_recipient_user: + azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientUserOperations + :ivar workspace_notification_recipient_email: WorkspaceNotificationRecipientEmailOperations + operations + :vartype workspace_notification_recipient_email: + azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientEmailOperations + :ivar workspace_policy_fragment: WorkspacePolicyFragmentOperations operations + :vartype workspace_policy_fragment: + azure.mgmt.apimanagement.aio.operations.WorkspacePolicyFragmentOperations + :ivar workspace_group: WorkspaceGroupOperations operations + :vartype workspace_group: azure.mgmt.apimanagement.aio.operations.WorkspaceGroupOperations + :ivar workspace_group_user: WorkspaceGroupUserOperations operations + :vartype workspace_group_user: + azure.mgmt.apimanagement.aio.operations.WorkspaceGroupUserOperations + :ivar workspace_subscription: WorkspaceSubscriptionOperations operations + :vartype workspace_subscription: + azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations + :ivar workspace_api_version_set: WorkspaceApiVersionSetOperations operations + :vartype workspace_api_version_set: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiVersionSetOperations + :ivar workspace_api: WorkspaceApiOperations operations + :vartype workspace_api: azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperations + :ivar workspace_api_revision: WorkspaceApiRevisionOperations operations + :vartype workspace_api_revision: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiRevisionOperations + :ivar workspace_api_release: WorkspaceApiReleaseOperations operations + :vartype workspace_api_release: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiReleaseOperations + :ivar workspace_api_operation: WorkspaceApiOperationOperations operations + :vartype workspace_api_operation: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationOperations + :ivar workspace_api_operation_policy: WorkspaceApiOperationPolicyOperations operations + :vartype workspace_api_operation_policy: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationPolicyOperations + :ivar workspace_api_policy: WorkspaceApiPolicyOperations operations + :vartype workspace_api_policy: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiPolicyOperations + :ivar workspace_api_schema: WorkspaceApiSchemaOperations operations + :vartype workspace_api_schema: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiSchemaOperations + :ivar workspace_product: WorkspaceProductOperations operations + :vartype workspace_product: azure.mgmt.apimanagement.aio.operations.WorkspaceProductOperations + :ivar workspace_product_api_link: WorkspaceProductApiLinkOperations operations + :vartype workspace_product_api_link: + azure.mgmt.apimanagement.aio.operations.WorkspaceProductApiLinkOperations + :ivar workspace_product_group_link: WorkspaceProductGroupLinkOperations operations + :vartype workspace_product_group_link: + azure.mgmt.apimanagement.aio.operations.WorkspaceProductGroupLinkOperations + :ivar workspace_product_policy: WorkspaceProductPolicyOperations operations + :vartype workspace_product_policy: + azure.mgmt.apimanagement.aio.operations.WorkspaceProductPolicyOperations + :ivar workspace_tag: WorkspaceTagOperations operations + :vartype workspace_tag: azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperations + :ivar workspace_tag_api_link: WorkspaceTagApiLinkOperations operations + :vartype workspace_tag_api_link: + azure.mgmt.apimanagement.aio.operations.WorkspaceTagApiLinkOperations + :ivar workspace_tag_operation_link: WorkspaceTagOperationLinkOperations operations + :vartype workspace_tag_operation_link: + azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperationLinkOperations + :ivar workspace_tag_product_link: WorkspaceTagProductLinkOperations operations + :vartype workspace_tag_product_link: + azure.mgmt.apimanagement.aio.operations.WorkspaceTagProductLinkOperations + :ivar workspace_api_export: WorkspaceApiExportOperations operations + :vartype workspace_api_export: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiExportOperations + :ivar operation_status: OperationStatusOperations operations + :vartype operation_status: azure.mgmt.apimanagement.aio.operations.OperationStatusOperations + :ivar operations_results: OperationsResultsOperations operations + :vartype operations_results: + azure.mgmt.apimanagement.aio.operations.OperationsResultsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -370,6 +549,11 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False + self.all_policies = AllPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_gateway = ApiGatewayOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_management_gateway_skus = ApiManagementGatewaySkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.api = ApiOperations(self._client, self._config, self._serialize, self._deserialize) self.api_revision = ApiRevisionOperations(self._client, self._config, self._serialize, self._deserialize) self.api_release = ApiReleaseOperations(self._client, self._config, self._serialize, self._deserialize) @@ -403,9 +587,6 @@ def __init__( self.api_wikis = ApiWikisOperations(self._client, self._config, self._serialize, self._deserialize) self.api_export = ApiExportOperations(self._client, self._config, self._serialize, self._deserialize) self.api_version_set = ApiVersionSetOperations(self._client, self._config, self._serialize, self._deserialize) - self.authorization_server = AuthorizationServerOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.authorization_provider = AuthorizationProviderOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -416,6 +597,9 @@ def __init__( self.authorization_access_policy = AuthorizationAccessPolicyOperations( self._client, self._config, self._serialize, self._deserialize ) + self.authorization_server = AuthorizationServerOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.backend = BackendOperations(self._client, self._config, self._serialize, self._deserialize) self.cache = CacheOperations(self._client, self._config, self._serialize, self._deserialize) self.certificate = CertificateOperations(self._client, self._config, self._serialize, self._deserialize) @@ -434,6 +618,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.diagnostic = DiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) + self.documentation = DocumentationOperations(self._client, self._config, self._serialize, self._deserialize) self.email_template = EmailTemplateOperations(self._client, self._config, self._serialize, self._deserialize) self.gateway = GatewayOperations(self._client, self._config, self._serialize, self._deserialize) self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( @@ -443,6 +628,9 @@ def __init__( self.gateway_certificate_authority = GatewayCertificateAuthorityOperations( self._client, self._config, self._serialize, self._deserialize ) + self.api_gateway_config_connection = ApiGatewayConfigConnectionOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.group = GroupOperations(self._client, self._config, self._serialize, self._deserialize) self.group_user = GroupUserOperations(self._client, self._config, self._serialize, self._deserialize) self.identity_provider = IdentityProviderOperations( @@ -470,6 +658,12 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.policy_fragment = PolicyFragmentOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_restriction = PolicyRestrictionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_restriction_validations = PolicyRestrictionValidationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.portal_config = PortalConfigOperations(self._client, self._config, self._serialize, self._deserialize) self.portal_revision = PortalRevisionOperations(self._client, self._config, self._serialize, self._deserialize) self.portal_settings = PortalSettingsOperations(self._client, self._config, self._serialize, self._deserialize) @@ -490,6 +684,10 @@ def __init__( self.product_policy = ProductPolicyOperations(self._client, self._config, self._serialize, self._deserialize) self.product_wiki = ProductWikiOperations(self._client, self._config, self._serialize, self._deserialize) self.product_wikis = ProductWikisOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_api_link = ProductApiLinkOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_group_link = ProductGroupLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.quota_by_counter_keys = QuotaByCounterKeysOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -505,6 +703,11 @@ def __init__( ) self.subscription = SubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) self.tag_resource = TagResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.tag_api_link = TagApiLinkOperations(self._client, self._config, self._serialize, self._deserialize) + self.tag_operation_link = TagOperationLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tag_product_link = TagProductLinkOperations(self._client, self._config, self._serialize, self._deserialize) self.tenant_access = TenantAccessOperations(self._client, self._config, self._serialize, self._deserialize) self.tenant_access_git = TenantAccessGitOperations( self._client, self._config, self._serialize, self._deserialize @@ -521,7 +724,109 @@ def __init__( self.user_confirmation_password = UserConfirmationPasswordOperations( self._client, self._config, self._serialize, self._deserialize ) - self.documentation = DocumentationOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_backend = WorkspaceBackendOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_certificate = WorkspaceCertificateOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_diagnostic = WorkspaceDiagnosticOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_diagnostic = WorkspaceApiDiagnosticOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_logger = WorkspaceLoggerOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_workspace_links = ApiManagementWorkspaceLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_management_workspace_link = ApiManagementWorkspaceLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace = WorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_policy = WorkspacePolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_named_value = WorkspaceNamedValueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_global_schema = WorkspaceGlobalSchemaOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_notification = WorkspaceNotificationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_notification_recipient_user = WorkspaceNotificationRecipientUserOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_notification_recipient_email = WorkspaceNotificationRecipientEmailOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_policy_fragment = WorkspacePolicyFragmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_group = WorkspaceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_group_user = WorkspaceGroupUserOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_subscription = WorkspaceSubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_version_set = WorkspaceApiVersionSetOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api = WorkspaceApiOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_api_revision = WorkspaceApiRevisionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_release = WorkspaceApiReleaseOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_operation = WorkspaceApiOperationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_operation_policy = WorkspaceApiOperationPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_policy = WorkspaceApiPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_schema = WorkspaceApiSchemaOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_product = WorkspaceProductOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_product_api_link = WorkspaceProductApiLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_product_group_link = WorkspaceProductGroupLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_product_policy = WorkspaceProductPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_tag = WorkspaceTagOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_tag_api_link = WorkspaceTagApiLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_tag_operation_link = WorkspaceTagOperationLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_tag_product_link = WorkspaceTagProductLinkOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_api_export = WorkspaceApiExportOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operation_status = OperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations_results = OperationsResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any @@ -550,7 +855,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "ApiManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_configuration.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_configuration.py index 6649dde49846..9a61b2c3710a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_configuration.py @@ -26,15 +26,15 @@ class ApiManagementClientConfiguration: # pylint: disable=too-many-instance-att :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-08-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2022-08-01") + api_version: str = kwargs.pop("api_version", "2024-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_patch.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_patch.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py index 36e30ba45094..6e3ccfbebf59 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py @@ -8,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import ApiManagementClientConfiguration if TYPE_CHECKING: diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/__init__.py index b22d1486cf46..79142cc42a85 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/__init__.py @@ -6,6 +6,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._all_policies_operations import AllPoliciesOperations +from ._api_gateway_operations import ApiGatewayOperations +from ._api_management_gateway_skus_operations import ApiManagementGatewaySkusOperations from ._api_operations import ApiOperations from ._api_revision_operations import ApiRevisionOperations from ._api_release_operations import ApiReleaseOperations @@ -27,11 +30,11 @@ from ._api_wikis_operations import ApiWikisOperations from ._api_export_operations import ApiExportOperations from ._api_version_set_operations import ApiVersionSetOperations -from ._authorization_server_operations import AuthorizationServerOperations from ._authorization_provider_operations import AuthorizationProviderOperations from ._authorization_operations import AuthorizationOperations from ._authorization_login_links_operations import AuthorizationLoginLinksOperations from ._authorization_access_policy_operations import AuthorizationAccessPolicyOperations +from ._authorization_server_operations import AuthorizationServerOperations from ._backend_operations import BackendOperations from ._cache_operations import CacheOperations from ._certificate_operations import CertificateOperations @@ -43,11 +46,13 @@ from ._api_management_service_skus_operations import ApiManagementServiceSkusOperations from ._api_management_service_operations import ApiManagementServiceOperations from ._diagnostic_operations import DiagnosticOperations +from ._documentation_operations import DocumentationOperations from ._email_template_operations import EmailTemplateOperations from ._gateway_operations import GatewayOperations from ._gateway_hostname_configuration_operations import GatewayHostnameConfigurationOperations from ._gateway_api_operations import GatewayApiOperations from ._gateway_certificate_authority_operations import GatewayCertificateAuthorityOperations +from ._api_gateway_config_connection_operations import ApiGatewayConfigConnectionOperations from ._group_operations import GroupOperations from ._group_user_operations import GroupUserOperations from ._identity_provider_operations import IdentityProviderOperations @@ -63,6 +68,8 @@ from ._policy_operations import PolicyOperations from ._policy_description_operations import PolicyDescriptionOperations from ._policy_fragment_operations import PolicyFragmentOperations +from ._policy_restriction_operations import PolicyRestrictionOperations +from ._policy_restriction_validations_operations import PolicyRestrictionValidationsOperations from ._portal_config_operations import PortalConfigOperations from ._portal_revision_operations import PortalRevisionOperations from ._portal_settings_operations import PortalSettingsOperations @@ -77,6 +84,8 @@ from ._product_policy_operations import ProductPolicyOperations from ._product_wiki_operations import ProductWikiOperations from ._product_wikis_operations import ProductWikisOperations +from ._product_api_link_operations import ProductApiLinkOperations +from ._product_group_link_operations import ProductGroupLinkOperations from ._quota_by_counter_keys_operations import QuotaByCounterKeysOperations from ._quota_by_period_keys_operations import QuotaByPeriodKeysOperations from ._region_operations import RegionOperations @@ -86,6 +95,9 @@ from ._api_management_skus_operations import ApiManagementSkusOperations from ._subscription_operations import SubscriptionOperations from ._tag_resource_operations import TagResourceOperations +from ._tag_api_link_operations import TagApiLinkOperations +from ._tag_operation_link_operations import TagOperationLinkOperations +from ._tag_product_link_operations import TagProductLinkOperations from ._tenant_access_operations import TenantAccessOperations from ._tenant_access_git_operations import TenantAccessGitOperations from ._tenant_configuration_operations import TenantConfigurationOperations @@ -94,13 +106,52 @@ from ._user_subscription_operations import UserSubscriptionOperations from ._user_identities_operations import UserIdentitiesOperations from ._user_confirmation_password_operations import UserConfirmationPasswordOperations -from ._documentation_operations import DocumentationOperations +from ._workspace_backend_operations import WorkspaceBackendOperations +from ._workspace_certificate_operations import WorkspaceCertificateOperations +from ._workspace_diagnostic_operations import WorkspaceDiagnosticOperations +from ._workspace_api_diagnostic_operations import WorkspaceApiDiagnosticOperations +from ._workspace_logger_operations import WorkspaceLoggerOperations +from ._api_management_workspace_links_operations import ApiManagementWorkspaceLinksOperations +from ._api_management_workspace_link_operations import ApiManagementWorkspaceLinkOperations +from ._workspace_operations import WorkspaceOperations +from ._workspace_policy_operations import WorkspacePolicyOperations +from ._workspace_named_value_operations import WorkspaceNamedValueOperations +from ._workspace_global_schema_operations import WorkspaceGlobalSchemaOperations +from ._workspace_notification_operations import WorkspaceNotificationOperations +from ._workspace_notification_recipient_user_operations import WorkspaceNotificationRecipientUserOperations +from ._workspace_notification_recipient_email_operations import WorkspaceNotificationRecipientEmailOperations +from ._workspace_policy_fragment_operations import WorkspacePolicyFragmentOperations +from ._workspace_group_operations import WorkspaceGroupOperations +from ._workspace_group_user_operations import WorkspaceGroupUserOperations +from ._workspace_subscription_operations import WorkspaceSubscriptionOperations +from ._workspace_api_version_set_operations import WorkspaceApiVersionSetOperations +from ._workspace_api_operations import WorkspaceApiOperations +from ._workspace_api_revision_operations import WorkspaceApiRevisionOperations +from ._workspace_api_release_operations import WorkspaceApiReleaseOperations +from ._workspace_api_operation_operations import WorkspaceApiOperationOperations +from ._workspace_api_operation_policy_operations import WorkspaceApiOperationPolicyOperations +from ._workspace_api_policy_operations import WorkspaceApiPolicyOperations +from ._workspace_api_schema_operations import WorkspaceApiSchemaOperations +from ._workspace_product_operations import WorkspaceProductOperations +from ._workspace_product_api_link_operations import WorkspaceProductApiLinkOperations +from ._workspace_product_group_link_operations import WorkspaceProductGroupLinkOperations +from ._workspace_product_policy_operations import WorkspaceProductPolicyOperations +from ._workspace_tag_operations import WorkspaceTagOperations +from ._workspace_tag_api_link_operations import WorkspaceTagApiLinkOperations +from ._workspace_tag_operation_link_operations import WorkspaceTagOperationLinkOperations +from ._workspace_tag_product_link_operations import WorkspaceTagProductLinkOperations +from ._workspace_api_export_operations import WorkspaceApiExportOperations +from ._operation_status_operations import OperationStatusOperations +from ._operations_results_operations import OperationsResultsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ + "AllPoliciesOperations", + "ApiGatewayOperations", + "ApiManagementGatewaySkusOperations", "ApiOperations", "ApiRevisionOperations", "ApiReleaseOperations", @@ -122,11 +173,11 @@ "ApiWikisOperations", "ApiExportOperations", "ApiVersionSetOperations", - "AuthorizationServerOperations", "AuthorizationProviderOperations", "AuthorizationOperations", "AuthorizationLoginLinksOperations", "AuthorizationAccessPolicyOperations", + "AuthorizationServerOperations", "BackendOperations", "CacheOperations", "CertificateOperations", @@ -138,11 +189,13 @@ "ApiManagementServiceSkusOperations", "ApiManagementServiceOperations", "DiagnosticOperations", + "DocumentationOperations", "EmailTemplateOperations", "GatewayOperations", "GatewayHostnameConfigurationOperations", "GatewayApiOperations", "GatewayCertificateAuthorityOperations", + "ApiGatewayConfigConnectionOperations", "GroupOperations", "GroupUserOperations", "IdentityProviderOperations", @@ -158,6 +211,8 @@ "PolicyOperations", "PolicyDescriptionOperations", "PolicyFragmentOperations", + "PolicyRestrictionOperations", + "PolicyRestrictionValidationsOperations", "PortalConfigOperations", "PortalRevisionOperations", "PortalSettingsOperations", @@ -172,6 +227,8 @@ "ProductPolicyOperations", "ProductWikiOperations", "ProductWikisOperations", + "ProductApiLinkOperations", + "ProductGroupLinkOperations", "QuotaByCounterKeysOperations", "QuotaByPeriodKeysOperations", "RegionOperations", @@ -181,6 +238,9 @@ "ApiManagementSkusOperations", "SubscriptionOperations", "TagResourceOperations", + "TagApiLinkOperations", + "TagOperationLinkOperations", + "TagProductLinkOperations", "TenantAccessOperations", "TenantAccessGitOperations", "TenantConfigurationOperations", @@ -189,7 +249,43 @@ "UserSubscriptionOperations", "UserIdentitiesOperations", "UserConfirmationPasswordOperations", - "DocumentationOperations", + "WorkspaceBackendOperations", + "WorkspaceCertificateOperations", + "WorkspaceDiagnosticOperations", + "WorkspaceApiDiagnosticOperations", + "WorkspaceLoggerOperations", + "ApiManagementWorkspaceLinksOperations", + "ApiManagementWorkspaceLinkOperations", + "WorkspaceOperations", + "WorkspacePolicyOperations", + "WorkspaceNamedValueOperations", + "WorkspaceGlobalSchemaOperations", + "WorkspaceNotificationOperations", + "WorkspaceNotificationRecipientUserOperations", + "WorkspaceNotificationRecipientEmailOperations", + "WorkspacePolicyFragmentOperations", + "WorkspaceGroupOperations", + "WorkspaceGroupUserOperations", + "WorkspaceSubscriptionOperations", + "WorkspaceApiVersionSetOperations", + "WorkspaceApiOperations", + "WorkspaceApiRevisionOperations", + "WorkspaceApiReleaseOperations", + "WorkspaceApiOperationOperations", + "WorkspaceApiOperationPolicyOperations", + "WorkspaceApiPolicyOperations", + "WorkspaceApiSchemaOperations", + "WorkspaceProductOperations", + "WorkspaceProductApiLinkOperations", + "WorkspaceProductGroupLinkOperations", + "WorkspaceProductPolicyOperations", + "WorkspaceTagOperations", + "WorkspaceTagApiLinkOperations", + "WorkspaceTagOperationLinkOperations", + "WorkspaceTagProductLinkOperations", + "WorkspaceApiExportOperations", + "OperationStatusOperations", + "OperationsResultsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_all_policies_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_all_policies_operations.py new file mode 100644 index 000000000000..033fc6bf49ea --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_all_policies_operations.py @@ -0,0 +1,141 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._all_policies_operations import build_list_by_service_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AllPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`all_policies` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AllPoliciesContract"]: + """Status of all policies of API Management services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An iterator like instance of either AllPoliciesContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AllPoliciesContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AllPoliciesCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AllPoliciesCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py index a7ef0d45eb39..435e0083c605 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_diagnostic_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +105,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DiagnosticCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,7 +128,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +143,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -193,7 +193,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,7 +217,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -260,7 +259,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -284,7 +283,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -302,7 +300,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -421,7 +419,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +456,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -474,15 +471,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("DiagnosticContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -601,7 +592,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -638,7 +629,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -656,7 +646,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -687,7 +677,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -712,7 +702,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py index deca47cc566c..879c07433fe9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_export_operations import build_get_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,8 +75,8 @@ async def get( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :param format: Format in which to export the Api Details to the Storage Blob with Sas Key valid - for 5 minutes. Known values are: "swagger-link", "wsdl-link", "wadl-link", "openapi-link", and - "openapi+json-link". Required. + for 5 minutes. New formats can be added in the future. Known values are: "swagger-link", + "wsdl-link", "wadl-link", "openapi-link", and "openapi+json-link". Required. :type format: str or ~azure.mgmt.apimanagement.models.ExportFormat :param export: Query parameter required to export the API details. "true" Required. :type export: str or ~azure.mgmt.apimanagement.models.ExportApi @@ -82,7 +84,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -107,7 +109,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -122,7 +123,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiExportResult", pipeline_response) + deserialized = self._deserialize("ApiExportResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_config_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_config_connection_operations.py new file mode 100644 index 000000000000..b1d5b661eaf6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_config_connection_operations.py @@ -0,0 +1,559 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._api_gateway_config_connection_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_gateway_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiGatewayConfigConnectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_gateway_config_connection` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_gateway( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiManagementGatewayConfigConnectionResource"]: + """List all API Management gateway config connections within a gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :return: An iterator like instance of either ApiManagementGatewayConfigConnectionResource or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayConfigConnectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_gateway_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayConfigConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, gateway_name: str, config_connection_name: str, **kwargs: Any + ) -> _models.ApiManagementGatewayConfigConnectionResource: + """Gets an API Management gateway config connection resource description. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :return: ApiManagementGatewayConfigConnectionResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayConfigConnectionResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApiManagementGatewayConfigConnectionResource", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + parameters: Union[_models.ApiManagementGatewayConfigConnectionResource, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementGatewayConfigConnectionResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + parameters: _models.ApiManagementGatewayConfigConnectionResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayConfigConnectionResource]: + """Creates or updates an API Management gateway config connection. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway config + connection operation. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either + ApiManagementGatewayConfigConnectionResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayConfigConnectionResource]: + """Creates or updates an API Management gateway config connection. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway config + connection operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either + ApiManagementGatewayConfigConnectionResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + parameters: Union[_models.ApiManagementGatewayConfigConnectionResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayConfigConnectionResource]: + """Creates or updates an API Management gateway config connection. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway config + connection operation. Is either a ApiManagementGatewayConfigConnectionResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + or IO[bytes] + :return: An instance of AsyncLROPoller that returns either + ApiManagementGatewayConfigConnectionResource or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiManagementGatewayConfigConnectionResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize( + "ApiManagementGatewayConfigConnectionResource", pipeline_response.http_response + ) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementGatewayConfigConnectionResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementGatewayConfigConnectionResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, gateway_name: str, config_connection_name: str, if_match: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, gateway_name: str, config_connection_name: str, if_match: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing API Management gateway config connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_operations.py new file mode 100644 index 000000000000..5cdc908f2140 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_operations.py @@ -0,0 +1,809 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._api_gateway_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiGatewayOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_gateway` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_or_update_initial( + self, + resource_group_name: str, + gateway_name: str, + parameters: Union[_models.ApiManagementGatewayResource, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementGatewayResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: _models.ApiManagementGatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayResource]: + """Creates or updates an API Management gateway. This is long running operation and could take + several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayResource]: + """Creates or updates an API Management gateway. This is long running operation and could take + several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: Union[_models.ApiManagementGatewayResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayResource]: + """Creates or updates an API Management gateway. This is long running operation and could take + several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Is either a ApiManagementGatewayResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementGatewayResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementGatewayResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + gateway_name: str, + parameters: Union[_models.ApiManagementGatewayUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementGatewayUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: _models.ApiManagementGatewayUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayResource]: + """Updates an existing API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayResource]: + """Updates an existing API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: Union[_models.ApiManagementGatewayUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayResource]: + """Updates an existing API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Is either a ApiManagementGatewayUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateParameters or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementGatewayResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementGatewayResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> _models.ApiManagementGatewayResource: + """Gets an API Management gateway resource description. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :return: ApiManagementGatewayResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiManagementGatewayResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial(self, resource_group_name: str, gateway_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementGatewayResource]: + """Deletes an existing API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :return: An instance of AsyncLROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = self._deserialize("ApiManagementGatewayResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementGatewayResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementGatewayResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiManagementGatewayResource"]: + """List all API Management gateways within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ApiManagementGatewayResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.ApiManagementGatewayResource"]: + """List all API Management gateways within a subscription. + + :return: An iterator like instance of either ApiManagementGatewayResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py index 3e24b20f9db4..98888f8587af 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_issue_attachment_operations import ( build_create_or_update_request, build_delete_request, @@ -36,8 +35,11 @@ build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -108,7 +110,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IssueAttachmentCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,7 +134,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -148,7 +149,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -203,7 +203,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +228,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -274,7 +273,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,7 +298,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -317,7 +315,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -448,7 +446,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,7 +484,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -502,15 +499,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -551,7 +542,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -577,7 +568,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py index aeea6c77fcae..5472c59c8e3b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_issue_comment_operations import ( build_create_or_update_request, build_delete_request, @@ -36,8 +35,11 @@ build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -108,7 +110,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IssueCommentCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,7 +134,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -148,7 +149,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -203,7 +203,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,7 +228,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -274,7 +273,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,7 +298,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -317,7 +315,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueCommentContract", pipeline_response) + deserialized = self._deserialize("IssueCommentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -448,7 +446,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,7 +484,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -502,15 +499,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IssueCommentContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueCommentContract", pipeline_response) + deserialized = self._deserialize("IssueCommentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -551,7 +542,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -577,7 +568,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py index f1443090a530..1ab9ebf41555 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_issue_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -106,7 +108,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IssueCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,7 +132,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -146,7 +147,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -197,7 +197,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -221,7 +221,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -272,7 +271,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,7 +296,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -315,7 +313,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueContract", pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -434,7 +432,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,7 +469,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -487,15 +484,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IssueContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueContract", pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -614,7 +605,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -651,7 +642,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -669,7 +659,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueContract", pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -700,7 +690,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -725,7 +715,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py index 80276e2d9d75..e92b1a65581f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,35 +16,40 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_management_client_operations import build_perform_connectivity_check_async_request from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiManagementClientOperationsMixin(ApiManagementClientMixinABC): + async def _perform_connectivity_check_async_initial( # pylint: disable=name-too-long self, resource_group_name: str, service_name: str, connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ConnectivityCheckResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -56,7 +62,7 @@ async def _perform_connectivity_check_async_initial( # pylint: disable=name-too api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ConnectivityCheckResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -77,10 +83,10 @@ async def _perform_connectivity_check_async_initial( # pylint: disable=name-too headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -88,16 +94,22 @@ async def _perform_connectivity_check_async_initial( # pylint: disable=name-too response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -209,10 +221,11 @@ async def begin_perform_connectivity_check_async( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response) + deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_gateway_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_gateway_skus_operations.py new file mode 100644 index 000000000000..fbe48275168d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_gateway_skus_operations.py @@ -0,0 +1,144 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._api_management_gateway_skus_operations import build_list_available_skus_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiManagementGatewaySkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_management_gateway_skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_available_skus( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GatewayResourceSkuResult"]: + """Gets available SKUs for API Management gateway. + + Gets all available SKU for a given API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :return: An iterator like instance of either GatewayResourceSkuResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayResourceSkuResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GatewayResourceSkuResults] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_available_skus_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayResourceSkuResults", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py index ecc6845d5d2f..bd297ffe7d64 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_management_operations_operations import build_list_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,7 +85,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -99,7 +100,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py index eb084d2c6305..e80d64ce648e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_management_service_operations import ( build_apply_network_configuration_updates_request, build_backup_request, @@ -46,8 +47,11 @@ build_restore_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,8 +81,8 @@ async def _restore_initial( service_name: str, parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,7 +95,7 @@ async def _restore_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -112,10 +116,10 @@ async def _restore_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -123,18 +127,20 @@ async def _restore_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -253,10 +259,11 @@ async def begin_restore( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -286,8 +293,8 @@ async def _backup_initial( service_name: str, parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -300,7 +307,7 @@ async def _backup_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -321,10 +328,10 @@ async def _backup_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -332,17 +339,19 @@ async def _backup_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -456,10 +465,11 @@ async def begin_backup( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -489,8 +499,8 @@ async def _create_or_update_initial( service_name: str, parameters: Union[_models.ApiManagementServiceResource, IO[bytes]], **kwargs: Any - ) -> _models.ApiManagementServiceResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -503,7 +513,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ApiManagementServiceResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -524,10 +534,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -535,15 +545,15 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -658,10 +668,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -689,8 +700,8 @@ async def _update_initial( service_name: str, parameters: Union[_models.ApiManagementServiceUpdateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -703,7 +714,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -724,10 +735,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -735,16 +746,22 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -854,10 +871,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -894,7 +912,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -916,7 +934,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -931,17 +948,15 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_initial( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + async def _delete_initial(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -953,7 +968,7 @@ async def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -963,10 +978,10 @@ async def _delete_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -974,16 +989,22 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None + response_headers = {} if response.status_code == 202: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1022,12 +1043,17 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -1048,9 +1074,13 @@ def get_long_running_output(pipeline_response): ) async def _migrate_to_stv2_initial( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + self, + resource_group_name: str, + service_name: str, + parameters: Optional[Union[_models.MigrateToStv2Contract, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1058,24 +1088,39 @@ async def _migrate_to_stv2_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "MigrateToStv2Contract") + else: + _json = None _request = build_migrate_to_stv2_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1083,26 +1128,94 @@ async def _migrate_to_stv2_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + async def begin_migrate_to_stv2( + self, + resource_group_name: str, + service_name: str, + parameters: Optional[_models.MigrateToStv2Contract] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Upgrades an API Management service to the Stv2 platform. For details refer to + https://aka.ms/apim-migrate-stv2. This change is not reversible. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param parameters: Optional parameters supplied to migrate service. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.MigrateToStv2Contract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_migrate_to_stv2( + self, + resource_group_name: str, + service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Upgrades an API Management service to the Stv2 platform. For details refer to + https://aka.ms/apim-migrate-stv2. This change is not reversible. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param parameters: Optional parameters supplied to migrate service. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async async def begin_migrate_to_stv2( - self, resource_group_name: str, service_name: str, **kwargs: Any + self, + resource_group_name: str, + service_name: str, + parameters: Optional[Union[_models.MigrateToStv2Contract, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: """Upgrades an API Management service to the Stv2 platform. For details refer to https://aka.ms/apim-migrate-stv2. This change is not reversible. This is long running operation @@ -1113,16 +1226,20 @@ async def begin_migrate_to_stv2( :type resource_group_name: str :param service_name: The name of the API Management service. Required. :type service_name: str + :param parameters: Optional parameters supplied to migrate service. Is either a + MigrateToStv2Contract type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.MigrateToStv2Contract or IO[bytes] :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApiManagementServiceResource] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1131,16 +1248,19 @@ async def begin_migrate_to_stv2( raw_result = await self._migrate_to_stv2_initial( resource_group_name=resource_group_name, service_name=service_name, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1185,7 +1305,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiManagementServiceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1203,7 +1323,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1219,7 +1338,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1265,7 +1383,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApiManagementServiceReso api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiManagementServiceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1282,7 +1400,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1298,7 +1415,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1343,7 +1459,7 @@ async def get_sso_token( :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1365,7 +1481,6 @@ async def get_sso_token( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1380,7 +1495,7 @@ async def get_sso_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiManagementServiceGetSsoTokenResult", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceGetSsoTokenResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1439,7 +1554,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1471,7 +1586,6 @@ async def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1486,7 +1600,7 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiManagementServiceNameAvailabilityResult", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceNameAvailabilityResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1503,7 +1617,7 @@ async def get_domain_ownership_identifier( :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1523,7 +1637,6 @@ async def get_domain_ownership_identifier( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1538,7 +1651,9 @@ async def get_domain_ownership_identifier( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiManagementServiceGetDomainOwnershipIdentifierResult", pipeline_response) + deserialized = self._deserialize( + "ApiManagementServiceGetDomainOwnershipIdentifierResult", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1551,8 +1666,8 @@ async def _apply_network_configuration_updates_initial( # pylint: disable=name- service_name: str, parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO[bytes]]] = None, **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1565,7 +1680,7 @@ async def _apply_network_configuration_updates_initial( # pylint: disable=name- api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1589,10 +1704,10 @@ async def _apply_network_configuration_updates_initial( # pylint: disable=name- headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1600,18 +1715,20 @@ async def _apply_network_configuration_updates_initial( # pylint: disable=name- response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1733,10 +1850,11 @@ async def begin_apply_network_configuration_updates( # pylint: disable=name-too params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py index ff56c9c5e1b8..8a552f1920b0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_management_service_skus_operations import build_list_available_service_skus_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +79,7 @@ def list_available_service_skus( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceSkuResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,7 +98,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -112,7 +113,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py index aa5e770d4073..957ffc762b9c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_management_skus_operations import build_list_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ApiManagementSku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiManagementSkusResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,7 +87,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -101,7 +102,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_link_operations.py new file mode 100644 index 000000000000..7956524dcfe1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_link_operations.py @@ -0,0 +1,116 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._api_management_workspace_link_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiManagementWorkspaceLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_management_workspace_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> _models.ApiManagementWorkspaceLinksResource: + """Gets an API Management WorkspaceLink resource description. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :return: ApiManagementWorkspaceLinksResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementWorkspaceLinksResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiManagementWorkspaceLinksResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_links_operations.py new file mode 100644 index 000000000000..1a99f2e1539f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_links_operations.py @@ -0,0 +1,142 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._api_management_workspace_links_operations import build_list_by_service_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ApiManagementWorkspaceLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_management_workspace_links` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiManagementWorkspaceLinksResource"]: + """List all API Management workspaceLinks for a service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An iterator like instance of either ApiManagementWorkspaceLinksResource or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementWorkspaceLinksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiManagementWorkspaceLinksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py index 8c28e203c901..a159ad72d386 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_operation_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_api_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -110,7 +112,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -134,7 +136,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -150,7 +151,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -201,7 +201,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,7 +225,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -268,7 +267,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,7 +291,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -310,7 +308,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OperationContract", pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -429,7 +427,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,7 +464,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -482,15 +479,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("OperationContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OperationContract", pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -609,7 +600,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -646,7 +637,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -664,7 +654,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OperationContract", pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -695,7 +685,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,7 +710,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py index ccaab7636299..47ecdccdf17a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_operation_policy_operations import ( build_create_or_update_request, build_delete_request, @@ -33,8 +32,11 @@ build_get_request, build_list_by_operation_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +81,7 @@ async def list_by_operation( :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,7 +105,6 @@ async def list_by_operation( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,7 +119,7 @@ async def list_by_operation( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyCollection", pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -154,7 +155,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -179,7 +180,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -234,7 +234,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,7 +260,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -278,7 +277,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -406,7 +405,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,7 +443,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -460,15 +458,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -508,7 +500,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -534,7 +526,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py index 3ef0a274184d..dea7452fe3b9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_operations import ( build_create_or_update_request, build_delete_request, @@ -40,8 +41,11 @@ build_list_by_tags_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -115,7 +119,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -139,7 +143,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -155,7 +158,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -201,7 +203,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, api_ :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -224,7 +226,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, api_ headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,7 +263,7 @@ async def get(self, resource_group_name: str, service_name: str, api_id: str, ** :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -285,7 +286,6 @@ async def get(self, resource_group_name: str, service_name: str, api_id: str, ** headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -303,7 +303,7 @@ async def get(self, resource_group_name: str, service_name: str, api_id: str, ** response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -318,8 +318,8 @@ async def _create_or_update_initial( parameters: Union[_models.ApiCreateOrUpdateParameter, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.ApiContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,7 +332,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -355,32 +355,33 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -513,14 +514,19 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -644,7 +650,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -680,7 +686,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -698,15 +703,14 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, service_name: str, @@ -714,27 +718,8 @@ async def delete( # pylint: disable=inconsistent-return-statements if_match: str, delete_revisions: Optional[bool] = None, **kwargs: Any - ) -> None: - """Deletes the specified API of the API Management service instance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. - :type api_id: str - :param if_match: ETag of the Entity. ETag should match the current entity state from the header - response of the GET request or it should be * for unconditional update. Required. - :type if_match: str - :param delete_revisions: Delete all revisions of the Api. Default value is None. - :type delete_revisions: bool - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -746,7 +731,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -759,23 +744,112 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + if_match: str, + delete_revisions: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified API of the API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param delete_revisions: Delete all revisions of the Api. Default value is None. + :type delete_revisions: bool + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + if_match=if_match, + delete_revisions=delete_revisions, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_by_tags( @@ -823,7 +897,7 @@ def list_by_tags( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagResourceCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -846,7 +920,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -862,7 +935,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py index 7dd4eb436f2a..67f7a1d276ed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_policy_operations import ( build_create_or_update_request, build_delete_request, @@ -33,8 +32,11 @@ build_get_request, build_list_by_api_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +78,7 @@ async def list_by_api( :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,7 +101,6 @@ async def list_by_api( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -114,7 +115,7 @@ async def list_by_api( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyCollection", pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -146,7 +147,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,7 +171,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -221,7 +221,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,7 +246,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,15 +261,9 @@ async def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -386,7 +379,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,7 +416,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -439,15 +431,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -483,7 +469,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,7 +494,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py index 9bac8262d0d4..f29234b27a1a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_product_operations import build_list_by_apis_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +96,7 @@ def list_by_apis( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProductCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,7 +119,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -133,7 +134,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py index fc1b729d416d..8479877e3b74 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_release_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -105,7 +107,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiReleaseCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,7 +130,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -144,7 +145,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -195,7 +195,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,7 +219,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,7 +261,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,7 +285,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -304,7 +302,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiReleaseContract", pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -423,7 +421,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -460,7 +458,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -476,15 +473,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiReleaseContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiReleaseContract", pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -603,7 +594,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -640,7 +631,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -658,7 +648,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiReleaseContract", pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -689,7 +679,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -714,7 +704,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py index dcf50132e204..7b3ff280087e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_revision_operations import build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +96,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiRevisionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,7 +119,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -133,7 +134,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py index 782a6061539b..23ebfd6c9074 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_schema_operations import ( build_create_or_update_request, build_delete_request, @@ -38,8 +39,11 @@ build_get_request, build_list_by_api_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -104,7 +108,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SchemaCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -127,7 +131,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -143,7 +146,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -194,7 +196,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,7 +220,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -261,7 +262,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.SchemaContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -285,7 +286,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -303,7 +303,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SchemaContract", pipeline_response) + deserialized = self._deserialize("SchemaContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -319,8 +319,8 @@ async def _create_or_update_initial( parameters: Union[_models.SchemaContract, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.SchemaContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -333,7 +333,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SchemaContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -357,32 +357,33 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("SchemaContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("SchemaContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -528,14 +529,19 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("SchemaContract", pipeline_response) + deserialized = self._deserialize("SchemaContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -593,7 +599,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -619,7 +625,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py index eca451c070c7..1a11e3226bc5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_tag_description_operations import ( build_create_or_update_request, build_delete_request, @@ -36,8 +35,11 @@ build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -105,7 +107,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagDescriptionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,7 +130,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -144,7 +145,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -195,7 +195,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,7 +219,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,7 +261,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,7 +285,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -304,7 +302,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagDescriptionContract", pipeline_response) + deserialized = self._deserialize("TagDescriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -423,7 +421,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -460,7 +458,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -476,15 +473,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("TagDescriptionContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagDescriptionContract", pipeline_response) + deserialized = self._deserialize("TagDescriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -521,7 +512,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,7 +537,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py index 96169927d64f..f71384e8a6c3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_version_set_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -99,7 +101,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiVersionSetCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +123,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -137,7 +138,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -185,7 +185,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,7 +208,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -248,7 +247,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,7 +270,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -289,7 +287,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -396,7 +394,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,7 +430,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -448,15 +445,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -563,7 +554,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -599,7 +590,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -617,7 +607,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -645,7 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -669,7 +659,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wiki_operations.py index 43bc87ba9a75..aa9bc5006114 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wiki_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wiki_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_wiki_operations import ( build_create_or_update_request, build_delete_request, @@ -33,8 +32,11 @@ build_get_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +76,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, api_ :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,7 +99,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, api_ headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -137,7 +138,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -160,7 +161,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -178,7 +178,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -285,7 +285,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,7 +321,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -337,15 +336,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("WikiContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -452,7 +445,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,7 +481,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -506,7 +498,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -534,7 +526,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -558,7 +550,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wikis_operations.py index 7f810130fc5c..652a9496eb74 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wikis_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wikis_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._api_wikis_operations import build_list_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +94,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WikiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +117,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -131,7 +132,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py index e8bf6cabba8e..497807991b75 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,23 +21,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._authorization_access_policy_operations import ( build_create_or_update_request, build_delete_request, build_get_request, build_list_by_authorization_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -105,7 +107,7 @@ def list_by_authorization( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AuthorizationAccessPolicyCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +131,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -145,7 +146,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -202,7 +202,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -227,7 +227,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -245,7 +244,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response) + deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -368,7 +367,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,7 +405,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -422,15 +420,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response) + deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -468,7 +460,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -494,7 +486,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py index c923aa35aaf4..a897f5202873 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,17 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._authorization_login_links_operations import build_post_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -147,7 +149,7 @@ async def post( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,7 +185,6 @@ async def post( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -201,7 +202,7 @@ async def post( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationLoginResponseContract", pipeline_response) + deserialized = self._deserialize("AuthorizationLoginResponseContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py index 918b0be6666e..125aacee140b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._authorization_operations import ( build_confirm_consent_code_request, build_create_or_update_request, @@ -36,8 +35,11 @@ build_get_request, build_list_by_authorization_provider_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +105,7 @@ def list_by_authorization_provider( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AuthorizationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,7 +128,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +143,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -196,7 +196,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +220,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -238,7 +237,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationContract", pipeline_response) + deserialized = self._deserialize("AuthorizationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -351,7 +350,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,7 +387,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -404,15 +402,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationContract", pipeline_response) + deserialized = self._deserialize("AuthorizationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -447,7 +439,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,7 +464,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -586,7 +577,7 @@ async def confirm_consent_code( # pylint: disable=inconsistent-return-statement :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -622,7 +613,6 @@ async def confirm_consent_code( # pylint: disable=inconsistent-return-statement headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_provider_operations.py index a62b4a0d731e..53eb129fc696 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_provider_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,23 +21,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._authorization_provider_operations import ( build_create_or_update_request, build_delete_request, build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -99,7 +101,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AuthorizationProviderCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +123,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -137,7 +138,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -184,7 +184,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -207,7 +207,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -225,7 +224,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response) + deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -329,7 +328,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,7 +364,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -381,15 +379,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response) + deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -416,7 +408,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,7 +432,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py index 8f992607cc7c..38dba1b40b4f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._authorization_server_operations import ( build_create_or_update_request, build_delete_request, @@ -38,8 +37,11 @@ build_list_secrets_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +104,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AuthorizationServerCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -124,7 +126,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,7 +141,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -185,7 +185,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, auth :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,7 +208,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, auth headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -247,7 +246,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,7 +269,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -288,7 +286,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -392,7 +390,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -428,7 +426,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -444,15 +441,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -557,7 +548,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -593,7 +584,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -611,7 +601,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -638,7 +628,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -662,7 +652,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -697,7 +686,7 @@ async def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,7 +709,6 @@ async def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -738,7 +726,7 @@ async def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationServerSecretsContract", pipeline_response) + deserialized = self._deserialize("AuthorizationServerSecretsContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py index 8400c1866d51..d3f12146e726 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._backend_operations import ( build_create_or_update_request, build_delete_request, @@ -38,8 +37,11 @@ build_reconnect_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +104,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackendCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -124,7 +126,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,7 +141,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -186,7 +186,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, back :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,7 +209,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, back headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -249,7 +248,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -272,7 +271,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -290,7 +288,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("BackendContract", pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -397,7 +395,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -433,7 +431,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -449,15 +446,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("BackendContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("BackendContract", pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -564,7 +555,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,7 +591,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -618,7 +608,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("BackendContract", pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -646,7 +636,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -670,7 +660,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -779,7 +768,7 @@ async def reconnect( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -817,7 +806,6 @@ async def reconnect( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py index 38f9f19324b7..0fe872f62d15 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._cache_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +94,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CacheCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -113,7 +115,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -129,7 +130,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -175,7 +175,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, cach :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,7 +198,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, cach headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -238,7 +237,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,7 +260,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -279,7 +277,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CacheContract", pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -395,7 +393,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,7 +429,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -447,15 +444,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("CacheContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CacheContract", pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -562,7 +553,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -598,7 +589,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -616,7 +606,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CacheContract", pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -644,7 +634,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -668,7 +658,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py index afc6d711f935..a04a750fcc55 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._certificate_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_refresh_secret_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -105,7 +107,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CertificateCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,7 +130,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -144,7 +145,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -192,7 +192,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -215,7 +215,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,7 +254,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -278,7 +277,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -296,7 +294,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CertificateContract", pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -416,7 +414,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -452,7 +450,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -468,15 +465,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("CertificateContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CertificateContract", pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -504,7 +495,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,7 +519,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -568,7 +558,7 @@ async def refresh_secret( :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -591,7 +581,6 @@ async def refresh_secret( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -609,7 +598,7 @@ async def refresh_secret( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CertificateContract", pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py index 5fa69b548a9a..5e18d4c1fce5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._content_item_operations import ( build_create_or_update_request, build_delete_request, @@ -36,8 +35,11 @@ build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,7 +87,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContentItemCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,7 +107,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -121,7 +122,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -171,7 +171,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -195,7 +195,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,7 +235,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,7 +259,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -278,7 +276,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ContentItemContract", pipeline_response) + deserialized = self._deserialize("ContentItemContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -391,7 +389,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -428,7 +426,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -444,15 +441,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ContentItemContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ContentItemContract", pipeline_response) + deserialized = self._deserialize("ContentItemContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -487,7 +478,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -512,7 +503,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py index 555f8ae358f1..e22797896620 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,23 +21,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._content_type_operations import ( build_create_or_update_request, build_delete_request, build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,7 +85,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContentTypeCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,7 +104,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -118,7 +119,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -166,7 +166,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,7 +189,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,7 +206,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ContentTypeContract", pipeline_response) + deserialized = self._deserialize("ContentTypeContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -317,7 +316,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -353,7 +352,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -369,15 +367,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ContentTypeContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ContentTypeContract", pipeline_response) + deserialized = self._deserialize("ContentTypeContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -406,7 +398,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -430,7 +422,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py index 118980ca6af7..2915738aa15d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._delegation_settings_operations import ( build_create_or_update_request, build_get_entity_tag_request, @@ -33,8 +32,11 @@ build_list_secrets_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +73,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, **kw :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,7 +95,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, **kw headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -128,7 +129,7 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -150,7 +151,6 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -168,7 +168,7 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalDelegationSettings", pipeline_response) + deserialized = self._deserialize("PortalDelegationSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -263,7 +263,7 @@ async def update( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,7 +298,6 @@ async def update( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -404,7 +403,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -439,7 +438,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -454,7 +452,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalDelegationSettings", pipeline_response) + deserialized = self._deserialize("PortalDelegationSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -476,7 +474,7 @@ async def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +496,6 @@ async def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -513,7 +510,7 @@ async def list_secrets( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalSettingValidationKeyContract", pipeline_response) + deserialized = self._deserialize("PortalSettingValidationKeyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py index f142e9a597ee..19eca60208d8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,14 +31,16 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._deleted_services_operations import ( build_get_by_name_request, build_list_by_subscription_request, build_purge_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +80,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DeletedS api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedServicesCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,7 +97,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -109,7 +112,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -151,7 +153,7 @@ async def get_by_name(self, service_name: str, location: str, **kwargs: Any) -> :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,7 +175,6 @@ async def get_by_name(self, service_name: str, location: str, **kwargs: Any) -> headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -188,17 +189,15 @@ async def get_by_name(self, service_name: str, location: str, **kwargs: Any) -> error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedServiceContract", pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _purge_initial( - self, service_name: str, location: str, **kwargs: Any - ) -> Optional[_models.DeletedServiceContract]: - error_map = { + async def _purge_initial(self, service_name: str, location: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -210,7 +209,7 @@ async def _purge_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.DeletedServiceContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_purge_request( service_name=service_name, @@ -220,10 +219,10 @@ async def _purge_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -231,16 +230,19 @@ async def _purge_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("DeletedServiceContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -281,6 +283,7 @@ async def begin_purge( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -288,7 +291,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("DeletedServiceContract", pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py index b92f0d1a114c..ea92f868bf2f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._diagnostic_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -99,7 +101,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DiagnosticCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +123,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -137,7 +138,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -185,7 +185,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,7 +208,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -248,7 +247,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,7 +270,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -289,7 +287,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -396,7 +394,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,7 +430,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -448,15 +445,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("DiagnosticContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -563,7 +554,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -599,7 +590,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -617,7 +607,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -645,7 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -669,7 +659,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_documentation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_documentation_operations.py index 6041eadfd5d0..4fa61a26842f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_documentation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_documentation_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._documentation_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -99,7 +101,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DocumentationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,7 +123,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -137,7 +138,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -185,7 +185,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,7 +208,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -248,7 +247,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,7 +270,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -289,7 +287,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DocumentationContract", pipeline_response) + deserialized = self._deserialize("DocumentationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -396,7 +394,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,7 +430,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -448,15 +445,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("DocumentationContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DocumentationContract", pipeline_response) + deserialized = self._deserialize("DocumentationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -563,7 +554,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -599,7 +590,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -617,7 +607,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DocumentationContract", pipeline_response) + deserialized = self._deserialize("DocumentationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -645,7 +635,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -669,7 +659,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py index 5afa030b8d0e..868dfe57f7cc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._email_template_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -100,7 +102,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EmailTemplateCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -122,7 +124,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -138,7 +139,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -196,7 +196,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,7 +219,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -269,7 +268,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,7 +291,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -310,7 +308,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("EmailTemplateContract", pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -435,7 +433,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,7 +469,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -486,11 +483,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("EmailTemplateContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("EmailTemplateContract", pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -615,7 +608,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -651,7 +644,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -669,7 +661,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("EmailTemplateContract", pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -708,7 +700,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -732,7 +724,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py index 44ac6852140b..5fb39674022e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,23 +21,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._gateway_api_operations import ( build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -100,7 +102,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -123,7 +125,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -139,7 +140,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -190,7 +190,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -214,7 +214,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -336,7 +335,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +374,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -390,11 +388,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApiContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -422,7 +416,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -446,7 +440,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py index 0a4aab7cd7f8..36de7ace5d65 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._gateway_certificate_authority_operations import ( build_create_or_update_request, build_delete_request, @@ -36,8 +35,11 @@ build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +104,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GatewayCertificateAuthorityCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,7 +127,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -141,7 +142,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -192,7 +192,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,7 +216,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -259,7 +258,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +282,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,7 +299,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -421,7 +419,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +456,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -474,15 +471,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -519,7 +510,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -544,7 +535,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py index 02dbddaafcec..0a37e52ea810 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._gateway_hostname_configuration_operations import ( build_create_or_update_request, build_delete_request, @@ -36,8 +35,11 @@ build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -104,7 +106,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GatewayHostnameConfigurationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -127,7 +129,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -143,7 +144,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -195,7 +195,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,7 +219,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,7 +261,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,7 +285,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -304,7 +302,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -424,7 +422,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,7 +459,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -477,15 +474,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -516,7 +507,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,7 +532,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py index c17451ca21cd..00bdcd8cc2c6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,28 +21,32 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._gateway_operations import ( build_create_or_update_request, build_delete_request, build_generate_token_request, build_get_entity_tag_request, build_get_request, + build_invalidate_debug_credentials_request, build_list_by_service_request, + build_list_debug_credentials_request, build_list_keys_request, + build_list_trace_request, build_regenerate_key_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -104,7 +109,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GatewayCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,7 +131,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +146,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -188,7 +191,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, gate :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,7 +214,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, gate headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -251,7 +253,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,7 +276,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -292,7 +293,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayContract", pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -398,7 +399,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,7 +435,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -450,15 +450,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GatewayContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayContract", pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -564,7 +558,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,7 +594,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -618,7 +611,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayContract", pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -646,7 +639,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -670,7 +663,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -706,7 +698,7 @@ async def list_keys( :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -729,7 +721,6 @@ async def list_keys( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -747,7 +738,7 @@ async def list_keys( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayKeysContract", pipeline_response) + deserialized = self._deserialize("GatewayKeysContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -843,7 +834,7 @@ async def regenerate_key( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -878,7 +869,6 @@ async def regenerate_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -983,7 +973,7 @@ async def generate_token( :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1018,7 +1008,6 @@ async def generate_token( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1033,7 +1022,354 @@ async def generate_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GatewayTokenContract", pipeline_response) + deserialized = self._deserialize("GatewayTokenContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def invalidate_debug_credentials( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any + ) -> None: + """Action is invalidating all debug credentials issued for gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_invalidate_debug_credentials_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def list_debug_credentials( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayListDebugCredentialsContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayDebugCredentialsContract: + """Create new debug credentials for gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List debug credentials properties. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayDebugCredentialsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_debug_credentials( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayDebugCredentialsContract: + """Create new debug credentials for gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List debug credentials properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayDebugCredentialsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_debug_credentials( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayListDebugCredentialsContract, IO[bytes]], + **kwargs: Any + ) -> _models.GatewayDebugCredentialsContract: + """Create new debug credentials for gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List debug credentials properties. Is either a + GatewayListDebugCredentialsContract type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContract or + IO[bytes] + :return: GatewayDebugCredentialsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayDebugCredentialsContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayListDebugCredentialsContract") + + _request = build_list_debug_credentials_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayDebugCredentialsContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def list_trace( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayListTraceContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Dict[str, Any]: + """Fetches trace collected by gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List trace properties. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListTraceContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to any or the result of cls(response) + :rtype: dict[str, any] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_trace( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Dict[str, Any]: + """Fetches trace collected by gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List trace properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to any or the result of cls(response) + :rtype: dict[str, any] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_trace( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayListTraceContract, IO[bytes]], + **kwargs: Any + ) -> Dict[str, Any]: + """Fetches trace collected by gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List trace properties. Is either a GatewayListTraceContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListTraceContract or IO[bytes] + :return: dict mapping str to any or the result of cls(response) + :rtype: dict[str, any] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Dict[str, Any]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayListTraceContract") + + _request = build_list_trace_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("{object}", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py index a3de1118cb3e..1b6bd47cc6ec 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._global_schema_operations import ( build_create_or_update_request, build_delete_request, @@ -38,8 +39,11 @@ build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -101,7 +105,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GlobalSchemaCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -123,7 +127,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -139,7 +142,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -185,7 +187,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, sche :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,7 +210,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, sche headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -248,7 +249,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,7 +272,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -289,7 +289,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -304,8 +304,8 @@ async def _create_or_update_initial( parameters: Union[_models.GlobalSchemaContract, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.GlobalSchemaContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,7 +318,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.GlobalSchemaContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -341,32 +341,33 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -502,14 +503,19 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -554,7 +560,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -578,7 +584,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_operations.py index 555b58801e64..8b212f1a35ce 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._graph_ql_api_resolver_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_api_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -106,7 +108,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResolverCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +131,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -145,7 +146,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -196,7 +196,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +220,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -263,7 +262,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.ResolverContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,7 +286,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -305,7 +303,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ResolverContract", pipeline_response) + deserialized = self._deserialize("ResolverContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -424,7 +422,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ResolverContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,7 +459,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -477,15 +474,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ResolverContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ResolverContract", pipeline_response) + deserialized = self._deserialize("ResolverContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -604,7 +595,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.ResolverContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -641,7 +632,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -659,7 +649,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ResolverContract", pipeline_response) + deserialized = self._deserialize("ResolverContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -690,7 +680,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,7 +705,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_policy_operations.py index 62c4dce33e88..0bc241c8f293 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_policy_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._graph_ql_api_resolver_policy_operations import ( build_create_or_update_request, build_delete_request, @@ -36,8 +35,11 @@ build_get_request, build_list_by_resolver_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +91,7 @@ def list_by_resolver( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,7 +112,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -126,7 +127,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -186,7 +186,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,7 +211,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -266,7 +265,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,7 +291,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -310,7 +308,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -438,7 +436,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -476,7 +474,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -492,15 +489,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -540,7 +531,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +557,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py index 66fe9a062bc9..5eb97bdb58ec 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +105,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,7 +127,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -141,7 +142,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -187,7 +187,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, grou :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -210,7 +210,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, grou headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -250,7 +249,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -273,7 +272,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -291,7 +289,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GroupContract", pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -398,7 +396,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,7 +432,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -450,15 +447,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GroupContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GroupContract", pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -565,7 +556,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -601,7 +592,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -619,7 +609,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GroupContract", pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -647,7 +637,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -671,7 +661,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py index e76b8629c58d..56504d72706b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,23 +20,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._group_user_operations import ( build_check_entity_exists_request, build_create_request, build_delete_request, build_list_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +105,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UserCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,7 +128,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +143,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -193,7 +193,7 @@ async def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,7 +217,6 @@ async def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -257,7 +256,7 @@ async def create( :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,7 +280,6 @@ async def create( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -296,11 +294,7 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("UserContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("UserContract", pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -328,7 +322,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -352,7 +346,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py index 8124d13b6033..cbcb502a794d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._identity_provider_operations import ( build_create_or_update_request, build_delete_request, @@ -38,8 +37,11 @@ build_list_secrets_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -90,7 +92,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IdentityProviderList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,7 +111,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +126,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -177,7 +177,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -200,7 +200,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -245,7 +244,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -268,7 +267,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -286,7 +284,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IdentityProviderContract", pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -393,7 +391,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -429,7 +427,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -445,15 +442,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IdentityProviderContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IdentityProviderContract", pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -561,7 +552,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -597,7 +588,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -615,7 +605,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IdentityProviderContract", pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -648,7 +638,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -672,7 +662,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -712,7 +701,7 @@ async def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -735,7 +724,6 @@ async def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -753,7 +741,7 @@ async def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ClientSecretContract", pipeline_response) + deserialized = self._deserialize("ClientSecretContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py index 7c44f282deeb..066a5bc205de 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,18 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._issue_operations import build_get_request, build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +96,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IssueCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -116,7 +118,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -132,7 +133,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -180,7 +180,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,7 +203,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -221,7 +220,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueContract", pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py index 1b0664de5d3e..1158e7f6836c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._logger_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -104,7 +106,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LoggerCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,7 +128,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +143,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -188,7 +188,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, logg :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -211,7 +211,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, logg headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -251,7 +250,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,7 +273,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -292,7 +290,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("LoggerContract", pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -399,7 +397,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -435,7 +433,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -451,15 +448,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("LoggerContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("LoggerContract", pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -566,7 +557,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -602,7 +593,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -620,7 +610,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("LoggerContract", pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -648,7 +638,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -672,7 +662,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py index 3e912822bda3..86fd8b0effb4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._named_value_operations import ( build_create_or_update_request, build_delete_request, @@ -41,8 +42,11 @@ build_refresh_secret_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -111,7 +115,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NamedValueCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -134,7 +138,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -150,7 +153,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -197,7 +199,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +222,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -259,7 +260,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -282,7 +283,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -300,7 +300,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -315,8 +315,8 @@ async def _create_or_update_initial( parameters: Union[_models.NamedValueCreateContract, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.NamedValueContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -329,7 +329,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.NamedValueContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -352,32 +352,33 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("NamedValueContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -507,14 +508,19 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -546,8 +552,8 @@ async def _update_initial( if_match: str, parameters: Union[_models.NamedValueUpdateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.NamedValueContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -560,7 +566,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.NamedValueContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -583,10 +589,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -594,16 +600,25 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -733,6 +748,7 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -740,7 +756,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -784,7 +800,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -808,7 +824,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -843,7 +858,7 @@ async def list_value( :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -866,7 +881,6 @@ async def list_value( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -884,7 +898,7 @@ async def list_value( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueSecretContract", pipeline_response) + deserialized = self._deserialize("NamedValueSecretContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -893,8 +907,8 @@ async def list_value( async def _refresh_secret_initial( self, resource_group_name: str, service_name: str, named_value_id: str, **kwargs: Any - ) -> Optional[_models.NamedValueContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -906,7 +920,7 @@ async def _refresh_secret_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.NamedValueContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_refresh_secret_request( resource_group_name=resource_group_name, @@ -917,10 +931,10 @@ async def _refresh_secret_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -928,16 +942,25 @@ async def _refresh_secret_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -981,6 +1004,7 @@ async def begin_refresh_secret( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -988,7 +1012,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py index f38a7f53653a..840be779a3fe 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, List, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, List, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._network_status_operations import build_list_by_location_request, build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +70,7 @@ async def list_by_service( :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,7 +92,6 @@ async def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -105,7 +106,7 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("[NetworkStatusContractByLocation]", pipeline_response) + deserialized = self._deserialize("[NetworkStatusContractByLocation]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -132,7 +133,7 @@ async def list_by_location( :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,7 +156,6 @@ async def list_by_location( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -170,7 +170,7 @@ async def list_by_location( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NetworkStatusContract", pipeline_response) + deserialized = self._deserialize("NetworkStatusContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py index 32518cdedc6a..b64760c7a48f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,22 +20,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._notification_operations import ( build_create_or_update_request, build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -90,7 +92,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NotificationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,7 +113,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -127,7 +128,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -181,7 +181,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.NotificationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,7 +204,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -219,7 +218,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NotificationContract", pipeline_response) + deserialized = self._deserialize("NotificationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -254,7 +253,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.NotificationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -278,7 +277,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -293,7 +291,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NotificationContract", pipeline_response) + deserialized = self._deserialize("NotificationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py index 9525272c57b7..0ff51c008e5c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,22 +18,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._notification_recipient_email_operations import ( build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_notification_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +82,7 @@ async def list_by_notification( :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,7 +105,6 @@ async def list_by_notification( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,7 +119,7 @@ async def list_by_notification( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecipientEmailCollection", pipeline_response) + deserialized = self._deserialize("RecipientEmailCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -152,7 +153,7 @@ async def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -176,7 +177,6 @@ async def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -222,7 +222,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,7 +246,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -261,11 +260,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecipientEmailContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecipientEmailContract", pipeline_response) + deserialized = self._deserialize("RecipientEmailContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -299,7 +294,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -323,7 +318,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py index 6e3db7b28d5c..dec28c4e67e4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,22 +18,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._notification_recipient_user_operations import ( build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_notification_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +82,7 @@ async def list_by_notification( :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,7 +105,6 @@ async def list_by_notification( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,7 +119,7 @@ async def list_by_notification( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecipientUserCollection", pipeline_response) + deserialized = self._deserialize("RecipientUserCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -153,7 +154,7 @@ async def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,7 +178,6 @@ async def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -224,7 +224,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,7 +248,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -263,11 +262,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecipientUserContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecipientUserContract", pipeline_response) + deserialized = self._deserialize("RecipientUserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -302,7 +297,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -326,7 +321,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py index 581718936e7f..e7099cd17bab 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._open_id_connect_provider_operations import ( build_create_or_update_request, build_delete_request, @@ -38,8 +37,11 @@ build_list_secrets_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +104,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OpenIdConnectProviderCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -124,7 +126,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,7 +141,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -185,7 +185,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, opid :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,7 +208,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, opid headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -247,7 +246,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,7 +269,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -288,7 +286,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -392,7 +390,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -428,7 +426,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -444,15 +441,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -557,7 +548,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -593,7 +584,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -611,7 +601,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -638,7 +628,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -662,7 +652,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -697,7 +686,7 @@ async def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,7 +709,6 @@ async def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -738,7 +726,7 @@ async def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ClientSecretContract", pipeline_response) + deserialized = self._deserialize("ClientSecretContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py index 8d098e3e845b..c06e0c529c74 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operation_operations import build_list_by_tags_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +104,7 @@ def list_by_tags( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagResourceCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,7 +128,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +143,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_status_operations.py new file mode 100644 index 000000000000..74b2dad86a57 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_status_operations.py @@ -0,0 +1,109 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._operation_status_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: + """Returns the current status of an async operation. + + :param location: The name of the Azure region. Required. + :type location: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationStatusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operations_results_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operations_results_operations.py new file mode 100644 index 000000000000..0bab2ee63372 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operations_results_operations.py @@ -0,0 +1,112 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._operations_results_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OperationsResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`operations_results` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( # pylint: disable=inconsistent-return-statements + self, location: str, operation_id: str, **kwargs: Any + ) -> None: + """Returns operation results for long running operations executing DELETE or PATCH on the + resource. + + :param location: The name of the Azure region. Required. + :type location: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py index d8b835cf8b2b..eb2d0534428a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._outbound_network_dependencies_endpoints_operations import build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +68,7 @@ async def list_by_service( :rtype: ~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,7 +90,6 @@ async def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -103,7 +104,7 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OutboundEnvironmentEndpointList", pipeline_response) + deserialized = self._deserialize("OutboundEnvironmentEndpointList", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py index 14d5e699a480..7cc89e42e95a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._policy_description_operations import build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +75,7 @@ async def list_by_service( :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,7 +98,6 @@ async def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -111,7 +112,7 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyDescriptionCollection", pipeline_response) + deserialized = self._deserialize("PolicyDescriptionCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py index 7b333551dae6..7eeeb9852000 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py @@ -7,27 +7,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._policy_fragment_operations import ( build_create_or_update_request, build_delete_request, @@ -36,8 +40,11 @@ build_list_by_service_request, build_list_references_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,8 +68,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list_by_service( + @distributed_trace + def list_by_service( self, resource_group_name: str, service_name: str, @@ -71,7 +78,7 @@ async def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> _models.PolicyFragmentCollection: + ) -> AsyncIterable["_models.PolicyFragmentContract"]: """Gets all policy fragments. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -92,57 +99,84 @@ async def list_by_service( :type top: int :param skip: Number of records to skip. Default value is None. :type skip: int - :return: PolicyFragmentCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentCollection + :return: An iterator like instance of either PolicyFragmentContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyFragmentContract] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyFragmentCollection] = kwargs.pop("cls", None) - _request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - orderby=orderby, - top=top, - skip=skip, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyFragmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("PolicyFragmentCollection", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get_entity_tag(self, resource_group_name: str, service_name: str, id: str, **kwargs: Any) -> bool: @@ -159,7 +193,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, id: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -182,7 +216,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, id: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -229,7 +262,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -253,7 +286,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -271,7 +303,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyFragmentContract", pipeline_response) + deserialized = self._deserialize("PolicyFragmentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -286,8 +318,8 @@ async def _create_or_update_initial( parameters: Union[_models.PolicyFragmentContract, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.PolicyFragmentContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -300,7 +332,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PolicyFragmentContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -323,35 +355,33 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyFragmentContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyFragmentContract", pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -484,14 +514,19 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("PolicyFragmentContract", pipeline_response) + deserialized = self._deserialize("PolicyFragmentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -535,7 +570,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,7 +594,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -604,7 +638,7 @@ async def list_references( :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -629,7 +663,6 @@ async def list_references( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -644,7 +677,7 @@ async def list_references( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceCollection", pipeline_response) + deserialized = self._deserialize("ResourceCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py index 3577a75500f8..cf0d770e3650 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py @@ -7,8 +7,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,14 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._policy_operations import ( build_create_or_update_request, build_delete_request, @@ -33,8 +35,11 @@ build_get_request, build_list_by_service_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,10 +63,10 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list_by_service( + @distributed_trace + def list_by_service( self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.PolicyCollection: + ) -> AsyncIterable["_models.PolicyContract"]: """Lists all the Global Policy definitions of the Api Management service. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -69,53 +74,79 @@ async def list_by_service( :type resource_group_name: str :param service_name: The name of the API Management service. Required. :type service_name: str - :return: PolicyCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) - _request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - return deserialized # type: ignore + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get_entity_tag( @@ -135,7 +166,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -158,7 +189,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -205,7 +235,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -229,7 +259,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -247,7 +276,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -351,7 +380,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -387,7 +416,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -403,15 +431,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -443,7 +465,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -467,7 +489,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_operations.py new file mode 100644 index 000000000000..cc2887466f35 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_operations.py @@ -0,0 +1,656 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._policy_restriction_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PolicyRestrictionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy_restriction` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyRestrictionContract"]: + """Gets all policy restrictions of API Management services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An iterator like instance of either PolicyRestrictionContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyRestrictionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyRestrictionCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyRestrictionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, policy_restriction_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the policy restriction in the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, policy_restriction_id: str, **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Get the policy restriction of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyRestrictionContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyRestrictionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + parameters: _models.PolicyRestrictionContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Creates or updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param parameters: The policy restriction to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Creates or updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param parameters: The policy restriction to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + parameters: Union[_models.PolicyRestrictionContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Creates or updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param parameters: The policy restriction to apply. Is either a PolicyRestrictionContract type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyRestrictionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyRestrictionContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyRestrictionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + if_match: str, + parameters: _models.PolicyRestrictionUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: The policy restriction to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: The policy restriction to apply. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + if_match: str, + parameters: Union[_models.PolicyRestrictionUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: The policy restriction to apply. Is either a PolicyRestrictionUpdateContract + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract or IO[bytes] + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyRestrictionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyRestrictionUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyRestrictionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes the policy restriction configuration of the Api Management Service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_validations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_validations_operations.py new file mode 100644 index 000000000000..96f4ef9ab168 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_validations_operations.py @@ -0,0 +1,176 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._policy_restriction_validations_operations import build_by_service_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PolicyRestrictionValidationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy_restriction_validations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _by_service_initial( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """Validate all policies of API Management services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An instance of AsyncLROPoller that returns either OperationResultContract or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationResultContract] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._by_service_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationResultContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OperationResultContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationResultContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_config_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_config_operations.py index 6e9b65e0193d..6110e02f93d2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_config_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_config_operations.py @@ -7,8 +7,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,14 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._portal_config_operations import ( build_create_or_update_request, build_get_entity_tag_request, @@ -33,8 +35,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,10 +63,10 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list_by_service( + @distributed_trace + def list_by_service( self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.PortalConfigCollection: + ) -> AsyncIterable["_models.PortalConfigContract"]: """Lists the developer portal configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -69,53 +74,80 @@ async def list_by_service( :type resource_group_name: str :param service_name: The name of the API Management service. Required. :type service_name: str - :return: PortalConfigCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigCollection + :return: An iterator like instance of either PortalConfigContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalConfigContract] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PortalConfigCollection] = kwargs.pop("cls", None) - _request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PortalConfigCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - return deserialized # type: ignore + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PortalConfigCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get_entity_tag( @@ -134,7 +166,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -157,7 +189,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -196,7 +227,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -219,7 +250,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -237,7 +267,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalConfigContract", pipeline_response) + deserialized = self._deserialize("PortalConfigContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -341,7 +371,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -377,7 +407,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -392,7 +421,7 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalConfigContract", pipeline_response) + deserialized = self._deserialize("PortalConfigContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -496,7 +525,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -532,7 +561,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -547,7 +575,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalConfigContract", pipeline_response) + deserialized = self._deserialize("PortalConfigContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py index f0c549b59fd3..ee62ac90d3cf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._portal_revision_operations import ( build_create_or_update_request, build_get_entity_tag_request, @@ -38,8 +39,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -109,7 +113,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PortalRevisionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -131,7 +135,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -147,7 +150,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -195,7 +197,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,7 +220,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -258,7 +259,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,7 +282,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -299,7 +299,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + deserialized = self._deserialize("PortalRevisionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -313,8 +313,8 @@ async def _create_or_update_initial( portal_revision_id: str, parameters: Union[_models.PortalRevisionContract, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PortalRevisionContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -327,7 +327,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PortalRevisionContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -349,27 +349,33 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [201, 202]: + if response.status_code not in [201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -494,14 +500,19 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + deserialized = self._deserialize("PortalRevisionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -533,8 +544,8 @@ async def _update_initial( if_match: str, parameters: Union[_models.PortalRevisionContract, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PortalRevisionContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -547,7 +558,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PortalRevisionContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -570,10 +581,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -581,16 +592,25 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -725,6 +745,7 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -732,7 +753,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + deserialized = self._deserialize("PortalRevisionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py index 77c5fd150ed8..b970f5d63dcc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._portal_settings_operations import build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +68,7 @@ async def list_by_service( :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,7 +90,6 @@ async def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -103,7 +104,7 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalSettingsCollection", pipeline_response) + deserialized = self._deserialize("PortalSettingsCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py index 03f3dee131ef..926865681a62 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connection_operations import ( build_create_or_update_request, build_delete_request, @@ -39,8 +40,11 @@ build_list_by_service_request, build_list_private_link_resources_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -87,7 +91,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,7 +110,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -122,7 +125,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -169,7 +171,7 @@ async def get_by_name( :rtype: ~azure.mgmt.apimanagement.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,7 +194,6 @@ async def get_by_name( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,7 +208,7 @@ async def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -221,8 +222,8 @@ async def _create_or_update_initial( private_endpoint_connection_name: str, private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -235,7 +236,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -257,10 +258,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -268,16 +269,22 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -396,10 +403,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -421,10 +429,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +444,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -447,10 +455,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -458,12 +466,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -491,7 +511,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -501,6 +521,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -537,7 +558,7 @@ async def list_private_link_resources( :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,7 +580,6 @@ async def list_private_link_resources( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -574,7 +594,7 @@ async def list_private_link_resources( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -598,7 +618,7 @@ async def get_private_link_resource( :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -621,7 +641,6 @@ async def get_private_link_resource( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -636,7 +655,7 @@ async def get_private_link_resource( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_link_operations.py new file mode 100644 index 000000000000..b3a8cea4c2aa --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_link_operations.py @@ -0,0 +1,460 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._product_api_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ProductApiLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_api_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductApiLinkContract"]: + """Lists a collection of the API links associated with a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ProductApiLinkContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductApiLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductApiLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, product_id: str, api_link_id: str, **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Gets the API link for the product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_link_id: str, + parameters: _models.ProductApiLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_link_id: str, + parameters: Union[_models.ProductApiLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Is either a ProductApiLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract or IO[bytes] + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductApiLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProductApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, product_id: str, api_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified API from the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py index 1cf613ff7711..b768af9af703 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,23 +20,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._product_api_operations import ( build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_product_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -103,7 +105,7 @@ def list_by_product( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,7 +128,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -142,7 +143,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -193,7 +193,7 @@ async def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,7 +217,6 @@ async def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -257,7 +256,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,7 +280,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -296,11 +294,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApiContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -328,7 +322,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -352,7 +346,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_link_operations.py new file mode 100644 index 000000000000..f4433574e2cb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_link_operations.py @@ -0,0 +1,460 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._product_group_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ProductGroupLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_group_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductGroupLinkContract"]: + """Lists a collection of the group links associated with a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| groupId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ProductGroupLinkContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductGroupLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductGroupLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, product_id: str, group_link_id: str, **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Gets the group link for the product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductGroupLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + parameters: _models.ProductGroupLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + parameters: Union[_models.ProductGroupLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Is either a ProductGroupLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract or IO[bytes] + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductGroupLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProductGroupLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, product_id: str, group_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified group from the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py index eb6e7f7ff8a3..66245ac4a0a6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,23 +20,24 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._product_group_operations import ( build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_product_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -99,7 +101,7 @@ def list_by_product( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -122,7 +124,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -138,7 +139,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -189,7 +189,7 @@ async def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,7 +213,6 @@ async def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -253,7 +252,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,7 +276,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -292,11 +290,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("GroupContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GroupContract", pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -324,7 +318,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -348,7 +342,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py index 895e92a68c2b..aa8317aca198 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._product_operations import ( build_create_or_update_request, build_delete_request, @@ -38,8 +37,11 @@ build_list_by_tags_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -111,7 +113,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProductCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -135,7 +137,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -151,7 +152,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -197,7 +197,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, prod :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,7 +220,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, prod headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -260,7 +259,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,7 +282,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,7 +299,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ProductContract", pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -408,7 +406,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,7 +442,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -460,15 +457,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ProductContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ProductContract", pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -575,7 +566,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -611,7 +602,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -629,7 +619,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ProductContract", pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -666,7 +656,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -691,7 +681,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -753,7 +742,7 @@ def list_by_tags( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagResourceCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -776,7 +765,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -792,7 +780,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py index b5b309742b0a..61c142666600 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py @@ -7,8 +7,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,14 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._product_policy_operations import ( build_create_or_update_request, build_delete_request, @@ -33,8 +35,11 @@ build_get_request, build_list_by_product_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,10 +63,10 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list_by_product( + @distributed_trace + def list_by_product( self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any - ) -> _models.PolicyCollection: + ) -> AsyncIterable["_models.PolicyContract"]: """Get the policy configuration at the Product level. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -72,54 +77,80 @@ async def list_by_product( :param product_id: Product identifier. Must be unique in the current API Management service instance. Required. :type product_id: str - :return: PolicyCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) - _request = build_list_by_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - return deserialized # type: ignore + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async async def get_entity_tag( @@ -146,7 +177,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,7 +201,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -221,7 +251,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,7 +276,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -264,7 +293,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -380,7 +409,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -417,7 +446,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -433,15 +461,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -477,7 +499,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -502,7 +524,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py index d14ab1fb3888..1136f4efefd7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._product_subscriptions_operations import build_list_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +104,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,7 +127,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -141,7 +142,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wiki_operations.py index a3ca08f65521..7fbf3c890f6e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wiki_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wiki_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._product_wiki_operations import ( build_create_or_update_request, build_delete_request, @@ -33,8 +32,11 @@ build_get_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +76,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, prod :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,7 +99,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, prod headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -137,7 +138,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -160,7 +161,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -178,7 +178,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -285,7 +285,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,7 +321,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -337,15 +336,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("WikiContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -452,7 +445,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,7 +481,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -506,7 +498,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -534,7 +526,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -558,7 +550,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wikis_operations.py index 2c2606a23e70..1158434368ef 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wikis_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wikis_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._product_wikis_operations import build_list_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -92,7 +94,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WikiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,7 +117,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -131,7 +132,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py index ee0aeabcc296..8d6e184402f6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,17 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._quota_by_counter_keys_operations import build_list_by_service_request, build_update_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +79,7 @@ async def list_by_service( :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,7 +102,6 @@ async def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -115,7 +116,7 @@ async def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaCounterCollection", pipeline_response) + deserialized = self._deserialize("QuotaCounterCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -221,7 +222,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +257,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -271,7 +271,7 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaCounterCollection", pipeline_response) + deserialized = self._deserialize("QuotaCounterCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py index 93f162491d7e..97dc9f2fd362 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,17 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._quota_by_period_keys_operations import build_get_request, build_update_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +81,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,7 +105,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -118,7 +119,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaCounterContract", pipeline_response) + deserialized = self._deserialize("QuotaCounterContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -230,7 +231,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -266,7 +267,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -281,7 +281,7 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaCounterContract", pipeline_response) + deserialized = self._deserialize("QuotaCounterContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py index 2430035d6d73..c3d01de808d9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._region_operations import build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,7 +77,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RegionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,7 +96,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -110,7 +111,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py index a9b25627e75c..823b836f895b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,14 +21,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._reports_operations import ( build_list_by_api_request, build_list_by_geo_request, @@ -38,8 +37,11 @@ build_list_by_time_request, build_list_by_user_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -101,7 +103,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -124,7 +126,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -140,7 +141,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -221,7 +221,7 @@ def list_by_user( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,7 +244,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -260,7 +259,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -341,7 +339,7 @@ def list_by_operation( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,7 +362,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -380,7 +377,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -460,7 +456,7 @@ def list_by_product( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,7 +479,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -499,7 +494,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -576,7 +570,7 @@ def list_by_geo( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -598,7 +592,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -614,7 +607,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -694,7 +686,7 @@ def list_by_subscription( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -717,7 +709,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -733,7 +724,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -818,7 +808,7 @@ def list_by_time( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -842,7 +832,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -858,7 +847,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -927,7 +915,7 @@ def list_by_request( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RequestReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -949,7 +937,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -965,7 +952,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py index 31ed31241af4..5bd8cdc452f5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,22 +19,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._sign_in_settings_operations import ( build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +72,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, **kw :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,7 +94,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, **kw headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -127,7 +128,7 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,7 +150,6 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -167,7 +167,7 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalSigninSettings", pipeline_response) + deserialized = self._deserialize("PortalSigninSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -262,7 +262,7 @@ async def update( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,7 +297,6 @@ async def update( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -403,7 +402,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,7 +437,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -453,7 +451,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalSigninSettings", pipeline_response) + deserialized = self._deserialize("PortalSigninSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py index 75ea36c46929..d392870c74e2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,22 +19,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._sign_up_settings_operations import ( build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +72,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, **kw :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,7 +94,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, **kw headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -127,7 +128,7 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,7 +150,6 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -167,7 +167,7 @@ async def get(self, resource_group_name: str, service_name: str, **kwargs: Any) response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalSignupSettings", pipeline_response) + deserialized = self._deserialize("PortalSignupSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -262,7 +262,7 @@ async def update( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,7 +297,6 @@ async def update( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -403,7 +402,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -438,7 +437,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -453,7 +451,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalSignupSettings", pipeline_response) + deserialized = self._deserialize("PortalSignupSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py index c503b0260b7f..4ea05614d677 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._subscription_operations import ( build_create_or_update_request, build_delete_request, @@ -40,8 +39,11 @@ build_regenerate_secondary_key_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -110,7 +112,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,7 +134,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -148,7 +149,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -195,7 +195,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, sid: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,7 +218,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, sid: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -258,7 +257,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,7 +280,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -299,7 +297,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionContract", pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -442,7 +440,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -480,7 +478,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -496,15 +493,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("SubscriptionContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionContract", pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -647,7 +638,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -685,7 +676,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -703,7 +693,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionContract", pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -731,7 +721,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -755,7 +745,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -791,7 +780,7 @@ async def regenerate_primary_key( # pylint: disable=inconsistent-return-stateme :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -814,7 +803,6 @@ async def regenerate_primary_key( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -850,7 +838,7 @@ async def regenerate_secondary_key( # pylint: disable=inconsistent-return-state :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -873,7 +861,6 @@ async def regenerate_secondary_key( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -909,7 +896,7 @@ async def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -932,7 +919,6 @@ async def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -950,7 +936,7 @@ async def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionKeysContract", pipeline_response) + deserialized = self._deserialize("SubscriptionKeysContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_api_link_operations.py new file mode 100644 index 000000000000..8bb14abfd440 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_api_link_operations.py @@ -0,0 +1,459 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._tag_api_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TagApiLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag_api_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TagApiLinkContract"]: + """Lists a collection of the API links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagApiLinkContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagApiLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TagApiLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, tag_id: str, api_link_id: str, **kwargs: Any + ) -> _models.TagApiLinkContract: + """Gets the API link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + api_link_id: str, + parameters: _models.TagApiLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + api_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + api_link_id: str, + parameters: Union[_models.TagApiLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Is either a TagApiLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract or IO[bytes] + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagApiLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, tag_id: str, api_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified API from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operation_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operation_link_operations.py new file mode 100644 index 000000000000..6a0eab44b551 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operation_link_operations.py @@ -0,0 +1,460 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._tag_operation_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TagOperationLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag_operation_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TagOperationLinkContract"]: + """Lists a collection of the operation links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| operationId + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagOperationLinkContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagOperationLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TagOperationLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, tag_id: str, operation_link_id: str, **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Gets the operation link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagOperationLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + parameters: _models.TagOperationLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + parameters: Union[_models.TagOperationLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Is either a TagOperationLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract or IO[bytes] + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagOperationLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagOperationLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, tag_id: str, operation_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified operation from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py index 0808b14c39ac..918bf3126e0c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._tag_operations import ( build_assign_to_api_request, build_assign_to_operation_request, @@ -52,8 +51,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -122,7 +124,7 @@ def list_by_operation( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -146,7 +148,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -162,7 +163,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -216,7 +216,7 @@ async def get_entity_state_by_operation( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -241,7 +241,6 @@ async def get_entity_state_by_operation( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -287,7 +286,7 @@ async def get_by_operation( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -312,7 +311,6 @@ async def get_by_operation( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -330,7 +328,7 @@ async def get_by_operation( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -361,7 +359,7 @@ async def assign_to_operation( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,7 +384,6 @@ async def assign_to_operation( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -401,11 +398,7 @@ async def assign_to_operation( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("TagContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -436,7 +429,7 @@ async def detach_from_operation( # pylint: disable=inconsistent-return-statemen :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,7 +454,6 @@ async def detach_from_operation( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -520,7 +512,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -543,7 +535,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -559,7 +550,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -610,7 +600,7 @@ async def get_entity_state_by_api( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -634,7 +624,6 @@ async def get_entity_state_by_api( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -677,7 +666,7 @@ async def get_by_api( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -701,7 +690,6 @@ async def get_by_api( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -719,7 +707,7 @@ async def get_by_api( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -747,7 +735,7 @@ async def assign_to_api( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -771,7 +759,6 @@ async def assign_to_api( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -787,15 +774,9 @@ async def assign_to_api( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("TagContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -823,7 +804,7 @@ async def detach_from_api( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -847,7 +828,6 @@ async def detach_from_api( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -906,7 +886,7 @@ def list_by_product( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -929,7 +909,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -945,7 +924,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -996,7 +974,7 @@ async def get_entity_state_by_product( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1020,7 +998,6 @@ async def get_entity_state_by_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1063,7 +1040,7 @@ async def get_by_product( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1087,7 +1064,6 @@ async def get_by_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1105,7 +1081,7 @@ async def get_by_product( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1133,7 +1109,7 @@ async def assign_to_product( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1157,7 +1133,6 @@ async def assign_to_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1172,11 +1147,7 @@ async def assign_to_product( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("TagContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1204,7 +1175,7 @@ async def detach_from_product( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1228,7 +1199,6 @@ async def detach_from_product( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1286,7 +1256,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1309,7 +1279,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1325,7 +1294,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1371,7 +1339,7 @@ async def get_entity_state(self, resource_group_name: str, service_name: str, ta :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1394,7 +1362,6 @@ async def get_entity_state(self, resource_group_name: str, service_name: str, ta headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1432,7 +1399,7 @@ async def get(self, resource_group_name: str, service_name: str, tag_id: str, ** :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1455,7 +1422,6 @@ async def get(self, resource_group_name: str, service_name: str, tag_id: str, ** headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1473,7 +1439,7 @@ async def get(self, resource_group_name: str, service_name: str, tag_id: str, ** response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1580,7 +1546,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1616,7 +1582,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1632,15 +1597,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("TagContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1747,7 +1706,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1783,7 +1742,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1801,7 +1759,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1829,7 +1787,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1853,7 +1811,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_product_link_operations.py new file mode 100644 index 000000000000..e2a72049353f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_product_link_operations.py @@ -0,0 +1,460 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._tag_product_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TagProductLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag_product_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TagProductLinkContract"]: + """Lists a collection of the product links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| productId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagProductLinkContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagProductLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TagProductLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, tag_id: str, product_link_id: str, **kwargs: Any + ) -> _models.TagProductLinkContract: + """Gets the product link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagProductLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + product_link_id: str, + parameters: _models.TagProductLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + product_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + product_link_id: str, + parameters: Union[_models.TagProductLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Is either a TagProductLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract or IO[bytes] + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagProductLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagProductLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, tag_id: str, product_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified product from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py index 7ef5e240eb89..15d18dad75b1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._tag_resource_operations import build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -101,7 +103,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagResourceCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -123,7 +125,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -139,7 +140,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py index 22ae77fbcf25..3a2bdf0abe7c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,20 +18,21 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._tenant_access_git_operations import ( build_regenerate_primary_key_request, build_regenerate_secondary_key_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +74,7 @@ async def regenerate_primary_key( # pylint: disable=inconsistent-return-stateme :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,7 +97,6 @@ async def regenerate_primary_key( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -131,7 +132,7 @@ async def regenerate_secondary_key( # pylint: disable=inconsistent-return-state :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,7 +155,6 @@ async def regenerate_secondary_key( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py index e5ab1f9079cf..fe67ba3a69a1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._tenant_access_operations import ( build_create_request, build_get_entity_tag_request, @@ -39,8 +38,11 @@ build_regenerate_secondary_key_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +91,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AccessInformationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,7 +111,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +126,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -173,7 +173,7 @@ async def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -196,7 +196,6 @@ async def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -236,7 +235,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -259,7 +258,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -277,7 +275,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AccessInformationContract", pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -385,7 +383,7 @@ async def create( :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -421,7 +419,6 @@ async def create( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -439,7 +436,7 @@ async def create( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AccessInformationContract", pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -547,7 +544,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,7 +580,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -601,7 +597,7 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AccessInformationContract", pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -626,7 +622,7 @@ async def regenerate_primary_key( # pylint: disable=inconsistent-return-stateme :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -649,7 +645,6 @@ async def regenerate_primary_key( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -685,7 +680,7 @@ async def regenerate_secondary_key( # pylint: disable=inconsistent-return-state :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -708,7 +703,6 @@ async def regenerate_secondary_key( # pylint: disable=inconsistent-return-state headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -744,7 +738,7 @@ async def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,7 +761,6 @@ async def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -785,7 +778,7 @@ async def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AccessInformationSecretsContract", pipeline_response) + deserialized = self._deserialize("AccessInformationSecretsContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py index a58d583d0d43..eea6e7b1cc33 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,27 +16,30 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._tenant_configuration_operations import ( build_deploy_request, build_get_sync_state_request, build_save_request, build_validate_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,8 +70,8 @@ async def _deploy_initial( configuration_name: Union[str, _models.ConfigurationIdName], parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationResultContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,7 +84,7 @@ async def _deploy_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OperationResultContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -102,10 +106,10 @@ async def _deploy_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -113,16 +117,22 @@ async def _deploy_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationResultContract", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -257,10 +267,11 @@ async def begin_deploy( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationResultContract", pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -291,8 +302,8 @@ async def _save_initial( configuration_name: Union[str, _models.ConfigurationIdName], parameters: Union[_models.SaveConfigurationParameter, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationResultContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,7 +316,7 @@ async def _save_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OperationResultContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -327,10 +338,10 @@ async def _save_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -338,16 +349,22 @@ async def _save_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationResultContract", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -482,10 +499,11 @@ async def begin_save( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationResultContract", pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -516,8 +534,8 @@ async def _validate_initial( configuration_name: Union[str, _models.ConfigurationIdName], parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationResultContract]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -530,7 +548,7 @@ async def _validate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OperationResultContract]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -552,10 +570,10 @@ async def _validate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -563,16 +581,22 @@ async def _validate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationResultContract", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -695,10 +719,11 @@ async def begin_validate( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationResultContract", pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -745,7 +770,7 @@ async def get_sync_state( :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -768,7 +793,6 @@ async def get_sync_state( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -783,7 +807,7 @@ async def get_sync_state( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TenantConfigurationSyncStateContract", pipeline_response) + deserialized = self._deserialize("TenantConfigurationSyncStateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py index 51561c84c15f..1d1ad0998e2f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,18 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._tenant_settings_operations import build_get_request, build_list_by_service_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +81,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TenantSettingsCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,7 +101,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -115,7 +116,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -166,7 +166,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,7 +189,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -207,7 +206,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TenantSettingsContract", pipeline_response) + deserialized = self._deserialize("TenantSettingsContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py index ad0c4bab9d48..c37812ec09ed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._user_confirmation_password_operations import build_send_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,7 +80,7 @@ async def send( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,7 +104,6 @@ async def send( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py index 281372237763..d0af2780ffb1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._user_group_operations import build_list_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -96,7 +98,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,7 +121,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -135,7 +136,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py index c02e5c5602a3..6135f967ae1d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._user_identities_operations import build_list_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +81,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UserIdentityCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,7 +101,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -115,7 +116,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py index ea76c91cc15a..0265004c9ca7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,18 +18,20 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._user_operations import ( build_create_or_update_request, build_delete_request, @@ -39,8 +42,11 @@ build_list_by_service_request, build_update_request, ) -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -108,7 +114,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UserCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -131,7 +137,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -147,7 +152,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -193,7 +197,7 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, user :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,7 +220,6 @@ async def get_entity_tag(self, resource_group_name: str, service_name: str, user headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -256,7 +259,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -279,7 +282,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -297,7 +299,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("UserContract", pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -413,7 +415,7 @@ async def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +452,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -466,15 +467,9 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("UserContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("UserContract", pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -581,7 +576,7 @@ async def update( :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -617,7 +612,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -635,15 +629,14 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("UserContract", pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, service_name: str, @@ -653,34 +646,8 @@ async def delete( # pylint: disable=inconsistent-return-statements notify: Optional[bool] = None, app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any - ) -> None: - """Deletes specific user. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param user_id: User identifier. Must be unique in the current API Management service instance. - Required. - :type user_id: str - :param if_match: ETag of the Entity. ETag should match the current entity state from the header - response of the GET request or it should be * for unconditional update. Required. - :type if_match: str - :param delete_subscriptions: Whether to delete user's subscription or not. Default value is - None. - :type delete_subscriptions: bool - :param notify: Send an Account Closed Email notification to the User. Default value is None. - :type notify: bool - :param app_type: Determines the type of application which send the create user request. Default - is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is - None. - :type app_type: str or ~azure.mgmt.apimanagement.models.AppType - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -692,7 +659,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -707,23 +674,123 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + service_name: str, + user_id: str, + if_match: str, + delete_subscriptions: Optional[bool] = None, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes specific user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param delete_subscriptions: Whether to delete user's subscription or not. Default value is + None. + :type delete_subscriptions: bool + :param notify: Send an Account Closed Email notification to the User. Default value is None. + :type notify: bool + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + if_match=if_match, + delete_subscriptions=delete_subscriptions, + notify=notify, + app_type=app_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def generate_sso_url( @@ -744,7 +811,7 @@ async def generate_sso_url( :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,7 +834,6 @@ async def generate_sso_url( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -782,7 +848,7 @@ async def generate_sso_url( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GenerateSsoUrlResult", pipeline_response) + deserialized = self._deserialize("GenerateSsoUrlResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -877,7 +943,7 @@ async def get_shared_access_token( :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -912,7 +978,6 @@ async def get_shared_access_token( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -927,7 +992,7 @@ async def get_shared_access_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("UserTokenResult", pipeline_response) + deserialized = self._deserialize("UserTokenResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py index 65f8bf298d87..5800056c32c3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,18 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._user_subscription_operations import build_get_request, build_list_request -from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +104,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,7 +127,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -141,7 +142,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -192,7 +192,7 @@ async def get( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,7 +216,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -234,7 +233,7 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionContract", pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_diagnostic_operations.py new file mode 100644 index 000000000000..d94d6cd6a659 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_diagnostic_operations.py @@ -0,0 +1,782 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_api_diagnostic_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_workspace_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiDiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_diagnostic` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DiagnosticContract"]: + """Lists all diagnostics of an API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either DiagnosticContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DiagnosticCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiagnosticCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + **kwargs: Any + ) -> _models.DiagnosticContract: + """Gets the details of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic for an API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic for an API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic for an API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Is either a DiagnosticContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + if_match: str, + parameters: _models.DiagnosticUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + if_match: str, + parameters: Union[_models.DiagnosticUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Is either a DiagnosticUpdateContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract or IO[bytes] + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified Diagnostic from an API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_export_operations.py new file mode 100644 index 000000000000..8debb1518733 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_export_operations.py @@ -0,0 +1,136 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_api_export_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_export` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + format: Union[str, _models.ExportFormat], + export: Union[str, _models.ExportApi], + **kwargs: Any + ) -> _models.ApiExportResult: + """Gets the details of the API specified by its identifier in the format specified to the Storage + Blob with SAS Key valid for 5 minutes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param format: Format in which to export the Api Details to the Storage Blob with Sas Key valid + for 5 minutes. Known values are: "swagger-link", "wsdl-link", "wadl-link", "openapi-link", and + "openapi+json-link". Required. + :type format: str or ~azure.mgmt.apimanagement.models.ExportFormat + :param export: Query parameter required to export the API details. "true" Required. + :type export: str or ~azure.mgmt.apimanagement.models.ExportApi + :return: ApiExportResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiExportResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + format=format, + export=export, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiExportResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_operations.py new file mode 100644 index 000000000000..8a64d81556cd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_operations.py @@ -0,0 +1,790 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_api_operation_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_api_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiOperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_operation` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.OperationContract"]: + """Lists a collection of the operations for the specified API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param tags: Include tags in the response. Default value is None. + :type tags: str + :return: An iterator like instance of either OperationContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + tags=tags, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API operation specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationContract: + """Gets the details of the API Operation specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + parameters: _models.OperationContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OperationContract: + """Creates a new operation in the API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OperationContract: + """Creates a new operation in the API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + parameters: Union[_models.OperationContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.OperationContract: + """Creates a new operation in the API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param parameters: Create parameters. Is either a OperationContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OperationContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + if_match: str, + parameters: _models.OperationUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OperationContract: + """Updates the details of the operation in the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Operation Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OperationContract: + """Updates the details of the operation in the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Operation Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + if_match: str, + parameters: Union[_models.OperationUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.OperationContract: + """Updates the details of the operation in the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Operation Update parameters. Is either a OperationUpdateContract type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract or IO[bytes] + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OperationUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified operation in the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_policy_operations.py new file mode 100644 index 000000000000..bcc929f32a4a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_policy_operations.py @@ -0,0 +1,612 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_api_operation_policy_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_operation_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiOperationPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_operation_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_operation( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyContract"]: + """Get the list of policy configuration at the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API operation policy specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Is either a PolicyContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the Api Operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operations.py new file mode 100644 index 000000000000..ec9b9d659cfd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operations.py @@ -0,0 +1,834 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._workspace_api_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + expand_api_version_set: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ApiContract"]: + """Lists all APIs of the workspace in an API Management service instance. + + .. seealso:: + - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-create-apis + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| isCurrent | filter | eq, ne | |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param tags: Include tags in the response. Default value is None. + :type tags: str + :param expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. + :type expand_api_version_set: bool + :return: An iterator like instance of either ApiContract or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + tags=tags, + expand_api_version_set=expand_api_version_set, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, **kwargs: Any + ) -> _models.ApiContract: + """Gets the details of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiCreateOrUpdateParameter") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: _models.ApiCreateOrUpdateParameter, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiContract]: + """Creates new or updates existing specified API of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ApiContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiContract]: + """Creates new or updates existing specified API of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ApiContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiContract]: + """Creates new or updates existing specified API of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param parameters: Create or update parameters. Is either a ApiCreateOrUpdateParameter type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either ApiContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + if_match: str, + parameters: _models.ApiUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates the specified API of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Update Contract parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates the specified API of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Update Contract parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + if_match: str, + parameters: Union[_models.ApiUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.ApiContract: + """Updates the specified API of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Update Contract parameters. Is either a ApiUpdateContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract or IO[bytes] + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + if_match: str, + delete_revisions: Optional[bool] = None, + **kwargs: Any + ) -> None: + """Deletes the specified API of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param delete_revisions: Delete all revisions of the Api. Default value is None. + :type delete_revisions: bool + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_revisions=delete_revisions, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_policy_operations.py new file mode 100644 index 000000000000..61ad89faec55 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_policy_operations.py @@ -0,0 +1,574 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_api_policy_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_api_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyContract"]: + """Get the policy configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API policy specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Is either a PolicyContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the Api. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_release_operations.py new file mode 100644 index 000000000000..a9a160736d62 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_release_operations.py @@ -0,0 +1,784 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_api_release_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiReleaseOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_release` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ApiReleaseContract"]: + """Lists all releases of an API. An API release is created when making an API Revision current. + Releases are also used to rollback to previous revisions. Results will be paged and can be + constrained by the $top and $skip parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| notes | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ApiReleaseContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiReleaseCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiReleaseCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + **kwargs: Any + ) -> bool: + """Returns the etag of an API release. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Returns the details of an API release. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + parameters: _models.ApiReleaseContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Creates a new Release for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Creates a new Release for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + parameters: Union[_models.ApiReleaseContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Creates a new Release for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param parameters: Create parameters. Is either a ApiReleaseContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiReleaseContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + if_match: str, + parameters: _models.ApiReleaseContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Updates the details of the release of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Release Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Updates the details of the release of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Release Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + if_match: str, + parameters: Union[_models.ApiReleaseContract, IO[bytes]], + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Updates the details of the release of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Release Update parameters. Is either a ApiReleaseContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or IO[bytes] + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiReleaseContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified release in the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_revision_operations.py new file mode 100644 index 000000000000..25225700276c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_revision_operations.py @@ -0,0 +1,169 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_api_revision_operations import build_list_by_service_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_revision` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ApiRevisionContract"]: + """Lists all revisions of an API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiRevision + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ApiRevisionContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiRevisionCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiRevisionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_schema_operations.py new file mode 100644 index 000000000000..0275d192d98a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_schema_operations.py @@ -0,0 +1,676 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._workspace_api_schema_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_api_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_schema` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SchemaContract"]: + """Get the schema configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| contentType + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either SchemaContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SchemaCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SchemaCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, schema_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the schema specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, schema_id: str, **kwargs: Any + ) -> _models.SchemaContract: + """Get the schema configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: SchemaContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SchemaContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SchemaContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + parameters: Union[_models.SchemaContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SchemaContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + parameters: _models.SchemaContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SchemaContract]: + """Creates or updates schema configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: The schema contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SchemaContract]: + """Creates or updates schema configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: The schema contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + parameters: Union[_models.SchemaContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.SchemaContract]: + """Creates or updates schema configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: The schema contents to apply. Is either a SchemaContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either SchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SchemaContract] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("SchemaContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SchemaContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SchemaContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + if_match: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + """Deletes the schema configuration at the Api. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param force: If true removes all references to the schema before deleting it. Default value is + None. + :type force: bool + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + force=force, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_version_set_operations.py new file mode 100644 index 000000000000..22a5c1a2ea5e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_version_set_operations.py @@ -0,0 +1,726 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_api_version_set_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceApiVersionSetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_api_version_set` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ApiVersionSetContract"]: + """Lists a collection of API Version Sets in the specified workspace with a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ApiVersionSetContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiVersionSetCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiVersionSetCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, version_set_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Api Version Set specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, version_set_id: str, **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Gets the details of the Api Version Set specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + parameters: _models.ApiVersionSetContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Creates or Updates a Api Version Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Creates or Updates a Api Version Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + parameters: Union[_models.ApiVersionSetContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Creates or Updates a Api Version Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param parameters: Create or update parameters. Is either a ApiVersionSetContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiVersionSetContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + if_match: str, + parameters: _models.ApiVersionSetUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Updates the details of the Api VersionSet specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Updates the details of the Api VersionSet specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + if_match: str, + parameters: Union[_models.ApiVersionSetUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Updates the details of the Api VersionSet specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a ApiVersionSetUpdateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters or IO[bytes] + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiVersionSetUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific Api Version Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_backend_operations.py new file mode 100644 index 000000000000..4dbe73d178f5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_backend_operations.py @@ -0,0 +1,728 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_backend_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_workspace_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceBackendOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_backend` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.BackendContract"]: + """Lists a collection of backends in the specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| url | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either BackendContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.BackendContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackendCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BackendCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, backend_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the backend specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, backend_id: str, **kwargs: Any + ) -> _models.BackendContract: + """Gets the details of the backend specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + parameters: _models.BackendContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Creates or Updates a backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Creates or Updates a backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + parameters: Union[_models.BackendContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.BackendContract: + """Creates or Updates a backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Create parameters. Is either a BackendContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackendContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + if_match: str, + parameters: _models.BackendUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Updates an existing backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Updates an existing backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + if_match: str, + parameters: Union[_models.BackendUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.BackendContract: + """Updates an existing backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a BackendUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters or IO[bytes] + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackendUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_certificate_operations.py new file mode 100644 index 000000000000..544e41459117 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_certificate_operations.py @@ -0,0 +1,646 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_certificate_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_workspace_request, + build_refresh_secret_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceCertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_certificate` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.CertificateContract"]: + """Lists a collection of all certificates in the specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| subject | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + thumbprint | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param is_key_vault_refresh_failed: When set to true, the response contains only certificates + entities which failed refresh. Default value is None. + :type is_key_vault_refresh_failed: bool + :return: An iterator like instance of either CertificateContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CertificateContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + is_key_vault_refresh_failed=is_key_vault_refresh_failed, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CertificateCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, certificate_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the certificate specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, certificate_id: str, **kwargs: Any + ) -> _models.CertificateContract: + """Gets the details of the certificate specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + parameters: _models.CertificateCreateOrUpdateParameters, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the backend. + + .. seealso:: + - + https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-mutual-certificates/ + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Create or Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the backend. + + .. seealso:: + - + https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-mutual-certificates/ + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Create or Update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the backend. + + .. seealso:: + - + https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-mutual-certificates/ + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Create or Update parameters. Is either a CertificateCreateOrUpdateParameters + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters or + IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CertificateCreateOrUpdateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def refresh_secret( + self, resource_group_name: str, service_name: str, workspace_id: str, certificate_id: str, **kwargs: Any + ) -> _models.CertificateContract: + """From KeyVault, Refresh the certificate being used for authentication with the backend. + + .. seealso:: + - + https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-mutual-certificates/ + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_diagnostic_operations.py new file mode 100644 index 000000000000..8b6b31b55ef3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_diagnostic_operations.py @@ -0,0 +1,726 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_diagnostic_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_workspace_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceDiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_diagnostic` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.DiagnosticContract"]: + """Lists all diagnostics in the specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either DiagnosticContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DiagnosticCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiagnosticCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, diagnostic_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, diagnostic_id: str, **kwargs: Any + ) -> _models.DiagnosticContract: + """Gets the details of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Is either a DiagnosticContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + if_match: str, + parameters: _models.DiagnosticUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + if_match: str, + parameters: Union[_models.DiagnosticUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Is either a DiagnosticUpdateContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract or IO[bytes] + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified Diagnostic. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_global_schema_operations.py new file mode 100644 index 000000000000..2c0c81a2781c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_global_schema_operations.py @@ -0,0 +1,645 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._workspace_global_schema_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceGlobalSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_global_schema` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.GlobalSchemaContract"]: + """Lists a collection of schemas registered with workspace in a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either GlobalSchemaContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalSchemaCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GlobalSchemaCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, schema_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Schema specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, schema_id: str, **kwargs: Any + ) -> _models.GlobalSchemaContract: + """Gets the details of the Schema specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: GlobalSchemaContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalSchemaContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GlobalSchemaContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: _models.GlobalSchemaContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either GlobalSchemaContract or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either GlobalSchemaContract or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: Create or update parameters. Is either a GlobalSchemaContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either GlobalSchemaContract or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GlobalSchemaContract] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.GlobalSchemaContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GlobalSchemaContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific Schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_operations.py new file mode 100644 index 000000000000..de73f30ee978 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_operations.py @@ -0,0 +1,730 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_group_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_group` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.GroupContract"]: + """Lists a collection of groups defined within a workspace in a service instance. + + .. seealso:: + - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-create-groups + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| externalId | filter | eq | |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either GroupContract or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GroupCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GroupCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, **kwargs: Any + ) -> _models.GroupContract: + """Gets the details of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + parameters: _models.GroupCreateParameters, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GroupContract: + """Creates or Updates a group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GroupContract: + """Creates or Updates a group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + parameters: Union[_models.GroupCreateParameters, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.GroupContract: + """Creates or Updates a group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Create parameters. Is either a GroupCreateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GroupCreateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + if_match: str, + parameters: _models.GroupUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GroupContract: + """Updates the details of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GroupContract: + """Updates the details of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + if_match: str, + parameters: Union[_models.GroupUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.GroupContract: + """Updates the details of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a GroupUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters or IO[bytes] + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GroupUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific group of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_user_operations.py new file mode 100644 index 000000000000..5f18e1832116 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_user_operations.py @@ -0,0 +1,381 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_group_user_operations import ( + build_check_entity_exists_request, + build_create_request, + build_delete_request, + build_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceGroupUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_group_user` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.UserContract"]: + """Lists a collection of user entities associated with the group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| firstName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, + le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either UserContract or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UserCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UserCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def check_entity_exists( + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, user_id: str, **kwargs: Any + ) -> bool: + """Checks that user entity specified by identifier is associated with the group entity. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def create( + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, user_id: str, **kwargs: Any + ) -> _models.UserContract: + """Add existing user to existing group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + _request = build_create_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UserContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, user_id: str, **kwargs: Any + ) -> None: + """Remove existing user from existing group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_logger_operations.py new file mode 100644 index 000000000000..3717551f2863 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_logger_operations.py @@ -0,0 +1,731 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_logger_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_workspace_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceLoggerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_logger` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.LoggerContract"]: + """Lists a collection of loggers in the specified workspace. + + .. seealso:: + - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-log-event-hubs + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| loggerType | filter | eq | |
| resourceId | filter | ge, le, eq, ne, gt, lt | + substringof, contains, startswith, endswith |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either LoggerContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.LoggerContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LoggerCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LoggerCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, logger_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the logger specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, logger_id: str, **kwargs: Any + ) -> _models.LoggerContract: + """Gets the details of the logger specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + parameters: _models.LoggerContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Creates or Updates a logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Creates or Updates a logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + parameters: Union[_models.LoggerContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.LoggerContract: + """Creates or Updates a logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Create parameters. Is either a LoggerContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LoggerContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + if_match: str, + parameters: _models.LoggerUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Updates an existing logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Updates an existing logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + if_match: str, + parameters: Union[_models.LoggerUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.LoggerContract: + """Updates an existing logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a LoggerUpdateContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract or IO[bytes] + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LoggerUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_named_value_operations.py new file mode 100644 index 000000000000..99002951becf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_named_value_operations.py @@ -0,0 +1,1099 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._workspace_named_value_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_list_value_request, + build_refresh_secret_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceNamedValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_named_value` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[Union[str, _models.KeyVaultRefreshState]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.NamedValueContract"]: + """Lists a collection of named values defined within a workspace in a service instance. + + .. seealso:: + - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-properties + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| tags | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith, any, all |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param is_key_vault_refresh_failed: Query parameter to fetch named value entities based on + refresh status. Known values are: "true" and "false". Default value is None. + :type is_key_vault_refresh_failed: str or ~azure.mgmt.apimanagement.models.KeyVaultRefreshState + :return: An iterator like instance of either NamedValueContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamedValueCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + is_key_vault_refresh_failed=is_key_vault_refresh_failed, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NamedValueCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> _models.NamedValueContract: + """Gets the details of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: NamedValueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamedValueCreateContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: _models.NamedValueCreateContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamedValueContract]: + """Creates or updates named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamedValueContract]: + """Creates or updates named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.NamedValueContract]: + """Creates or updates named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Is either a NamedValueCreateContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.NamedValueContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.NamedValueContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + parameters: Union[_models.NamedValueUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamedValueUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + parameters: _models.NamedValueUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamedValueContract]: + """Updates the specific named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamedValueContract]: + """Updates the specific named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + parameters: Union[_models.NamedValueUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.NamedValueContract]: + """Updates the specific named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a NamedValueUpdateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + if_match=if_match, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.NamedValueContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.NamedValueContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific named value from the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list_value( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> _models.NamedValueSecretContract: + """Gets the secret of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: NamedValueSecretContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamedValueSecretContract] = kwargs.pop("cls", None) + + _request = build_list_value_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueSecretContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _refresh_secret_initial( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_refresh_secret( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> AsyncLROPoller[_models.NamedValueContract]: + """Refresh the secret of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_secret_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.NamedValueContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.NamedValueContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_operations.py new file mode 100644 index 000000000000..fddcbdbf1ff5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_operations.py @@ -0,0 +1,314 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_notification_operations import ( + build_create_or_update_request, + build_get_request, + build_list_by_service_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceNotificationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_notification` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.NotificationContract"]: + """Lists a collection of properties defined within a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either NotificationContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NotificationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NotificationCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + **kwargs: Any + ) -> _models.NotificationContract: + """Gets the details of the Notification specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :return: NotificationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NotificationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.NotificationContract: + """Create or Update API Management publisher notification for the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: NotificationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NotificationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_email_operations.py new file mode 100644 index 000000000000..fefbcb21a250 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_email_operations.py @@ -0,0 +1,356 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_notification_recipient_email_operations import ( + build_check_entity_exists_request, + build_create_or_update_request, + build_delete_request, + build_list_by_notification_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceNotificationRecipientEmailOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_notification_recipient_email` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_notification( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + **kwargs: Any + ) -> _models.RecipientEmailCollection: + """Gets the list of the Notification Recipient Emails subscribed to a notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :return: RecipientEmailCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecipientEmailCollection] = kwargs.pop("cls", None) + + _request = build_list_by_notification_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecipientEmailCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + **kwargs: Any + ) -> bool: + """Determine if Notification Recipient Email subscribed to the notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param email: Email identifier. Required. + :type email: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + **kwargs: Any + ) -> _models.RecipientEmailContract: + """Adds the Email address to the list of Recipients for the Notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param email: Email identifier. Required. + :type email: str + :return: RecipientEmailContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecipientEmailContract] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecipientEmailContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + **kwargs: Any + ) -> None: + """Removes the email from the list of Notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param email: Email identifier. Required. + :type email: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_user_operations.py new file mode 100644 index 000000000000..6c78347b6579 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_user_operations.py @@ -0,0 +1,359 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_notification_recipient_user_operations import ( + build_check_entity_exists_request, + build_create_or_update_request, + build_delete_request, + build_list_by_notification_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceNotificationRecipientUserOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_notification_recipient_user` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_notification( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + **kwargs: Any + ) -> _models.RecipientUserCollection: + """Gets the list of the Notification Recipient User subscribed to the notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :return: RecipientUserCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecipientUserCollection] = kwargs.pop("cls", None) + + _request = build_list_by_notification_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecipientUserCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + **kwargs: Any + ) -> bool: + """Determine if the Notification Recipient User is subscribed to the notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + **kwargs: Any + ) -> _models.RecipientUserContract: + """Adds the API Management User to the list of Recipients for the Notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: RecipientUserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecipientUserContract] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecipientUserContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + **kwargs: Any + ) -> None: + """Removes the API Management user from the list of Notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_operations.py new file mode 100644 index 000000000000..54ca33761818 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_operations.py @@ -0,0 +1,678 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.WorkspaceContract"]: + """Lists all workspaces of the API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |

| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either WorkspaceContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.WorkspaceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.WorkspaceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("WorkspaceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> _models.WorkspaceContract: + """Gets the details of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.WorkspaceContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("WorkspaceContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + parameters: _models.WorkspaceContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceContract: + """Creates a new workspace or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceContract: + """Creates a new workspace or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + parameters: Union[_models.WorkspaceContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.WorkspaceContract: + """Creates a new workspace or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param parameters: Create parameters. Is either a WorkspaceContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkspaceContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "WorkspaceContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("WorkspaceContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + if_match: str, + parameters: _models.WorkspaceContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceContract: + """Updates the details of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Workspace Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceContract: + """Updates the details of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Workspace Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + if_match: str, + parameters: Union[_models.WorkspaceContract, IO[bytes]], + **kwargs: Any + ) -> _models.WorkspaceContract: + """Updates the details of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Workspace Update parameters. Is either a WorkspaceContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract or IO[bytes] + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkspaceContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "WorkspaceContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("WorkspaceContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, if_match: str, **kwargs: Any + ) -> None: + """Deletes the specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_fragment_operations.py new file mode 100644 index 000000000000..0a9334bd9d8a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_fragment_operations.py @@ -0,0 +1,725 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._workspace_policy_fragment_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_list_references_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspacePolicyFragmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_policy_fragment` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.PolicyFragmentContract"]: + """Gets all policy fragments defined within a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter, orderBy | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| value | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param orderby: OData order by query option. Default value is None. + :type orderby: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either PolicyFragmentContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyFragmentCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyFragmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + format: Optional[Union[str, _models.PolicyFragmentContentFormat]] = None, + **kwargs: Any + ) -> _models.PolicyFragmentContract: + """Gets a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param format: Policy fragment content format. Known values are: "xml" and "rawxml". Default + value is None. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :return: PolicyFragmentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyFragmentContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyFragmentContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: Union[_models.PolicyFragmentContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyFragmentContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: _models.PolicyFragmentContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PolicyFragmentContract]: + """Creates or updates a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either PolicyFragmentContract or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PolicyFragmentContract]: + """Creates or updates a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either PolicyFragmentContract or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: Union[_models.PolicyFragmentContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.PolicyFragmentContract]: + """Creates or updates a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Is either a PolicyFragmentContract + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of AsyncLROPoller that returns either PolicyFragmentContract or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyFragmentContract] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PolicyFragmentContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PolicyFragmentContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PolicyFragmentContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, id: str, if_match: str, **kwargs: Any + ) -> None: + """Deletes a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list_references( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> _models.ResourceCollection: + """Lists policy resources that reference the policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: ResourceCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ResourceCollection] = kwargs.pop("cls", None) + + _request = build_list_references_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_operations.py new file mode 100644 index 000000000000..31f3c8a10b72 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_operations.py @@ -0,0 +1,542 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_policy_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_api_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspacePolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> AsyncIterable["_models.PolicyContract"]: + """Get the policy configuration at the workspace level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the workspace policy specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Is either a PolicyContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_api_link_operations.py new file mode 100644 index 000000000000..08a69f78d694 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_api_link_operations.py @@ -0,0 +1,498 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_product_api_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceProductApiLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_product_api_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductApiLinkContract"]: + """Lists a collection of the API links associated with a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ProductApiLinkContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductApiLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductApiLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Gets the API link for the product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + parameters: _models.ProductApiLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + parameters: Union[_models.ProductApiLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Is either a ProductApiLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract or IO[bytes] + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductApiLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProductApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified API from the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_group_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_group_link_operations.py new file mode 100644 index 000000000000..1a1bd55d24eb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_group_link_operations.py @@ -0,0 +1,498 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_product_group_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceProductGroupLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_product_group_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductGroupLinkContract"]: + """Lists a collection of the group links associated with a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| groupId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ProductGroupLinkContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductGroupLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductGroupLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Gets the group link for the product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductGroupLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + parameters: _models.ProductGroupLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + parameters: Union[_models.ProductGroupLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Is either a ProductGroupLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract or IO[bytes] + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductGroupLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProductGroupLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified group from the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_operations.py new file mode 100644 index 000000000000..f68863a2281d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_operations.py @@ -0,0 +1,744 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_product_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_service_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_product` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ProductContract"]: + """Lists a collection of products in the specified workspace in a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | |
| groups | expand | | |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param expand_groups: When set to true, the response contains an array of groups that have + visibility to the product. The default is false. Default value is None. + :type expand_groups: bool + :param tags: Products which are part of a specific tag. Default value is None. + :type tags: str + :return: An iterator like instance of either ProductContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + expand_groups=expand_groups, + tags=tags, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ProductCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, product_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the product specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, product_id: str, **kwargs: Any + ) -> _models.ProductContract: + """Gets the details of the product specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + parameters: _models.ProductContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Creates or Updates a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Creates or Updates a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + parameters: Union[_models.ProductContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ProductContract: + """Creates or Updates a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create or update parameters. Is either a ProductContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + if_match: str, + parameters: _models.ProductUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Update existing product details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Update existing product details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + if_match: str, + parameters: Union[_models.ProductUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ProductContract: + """Update existing product details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a ProductUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters or IO[bytes] + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + if_match: str, + delete_subscriptions: Optional[bool] = None, + **kwargs: Any + ) -> None: + """Delete product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param delete_subscriptions: Delete existing subscriptions associated with the product or not. + Default value is None. + :type delete_subscriptions: bool + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_subscriptions=delete_subscriptions, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_policy_operations.py new file mode 100644 index 000000000000..fd70b459468d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_policy_operations.py @@ -0,0 +1,544 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_product_policy_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceProductPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_product_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_product( + self, resource_group_name: str, service_name: str, workspace_id: str, product_id: str, **kwargs: Any + ) -> _models.PolicyCollection: + """Get the policy configuration at the Product level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Get the ETag of the policy configuration at the Product level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the Product level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the Product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the Product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the Product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Is either a PolicyContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the Product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_subscription_operations.py new file mode 100644 index 000000000000..f9b5b4c4b03c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_subscription_operations.py @@ -0,0 +1,1003 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_subscription_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_tag_request, + build_get_request, + build_list_request, + build_list_secrets_request, + build_regenerate_primary_key_request, + build_regenerate_secondary_key_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceSubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_subscription` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SubscriptionContract"]: + """Lists all subscriptions of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| state | filter | eq | |
| user | expand | | + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either SubscriptionContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SubscriptionCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SubscriptionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the apimanagement subscription specified by its + identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> _models.SubscriptionContract: + """Gets the specified Subscription entity. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + parameters: _models.SubscriptionCreateParameters, + notify: Optional[bool] = None, + if_match: Optional[str] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionContract: + """Creates or updates the subscription of specified user to the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + parameters: IO[bytes], + notify: Optional[bool] = None, + if_match: Optional[str] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionContract: + """Creates or updates the subscription of specified user to the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + parameters: Union[_models.SubscriptionCreateParameters, IO[bytes]], + notify: Optional[bool] = None, + if_match: Optional[str] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> _models.SubscriptionContract: + """Creates or updates the subscription of specified user to the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Create parameters. Is either a SubscriptionCreateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters or IO[bytes] + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionCreateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + notify=notify, + if_match=if_match, + app_type=app_type, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + if_match: str, + parameters: _models.SubscriptionUpdateParameters, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionContract: + """Updates the details of a subscription specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + if_match: str, + parameters: IO[bytes], + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionContract: + """Updates the details of a subscription specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + if_match: str, + parameters: Union[_models.SubscriptionUpdateParameters, IO[bytes]], + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> _models.SubscriptionContract: + """Updates the details of a subscription specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a SubscriptionUpdateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters or IO[bytes] + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + if_match=if_match, + notify=notify, + app_type=app_type, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, if_match: str, **kwargs: Any + ) -> None: + """Deletes the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def regenerate_primary_key( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> None: + """Regenerates primary key of existing subscription of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_regenerate_primary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> None: + """Regenerates secondary key of existing subscription of the workspace in an API Management + service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_regenerate_secondary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list_secrets( + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> _models.SubscriptionKeysContract: + """Gets the specified Subscription keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionKeysContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SubscriptionKeysContract] = kwargs.pop("cls", None) + + _request = build_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionKeysContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_api_link_operations.py new file mode 100644 index 000000000000..3ce987e59bfd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_api_link_operations.py @@ -0,0 +1,497 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_tag_api_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceTagApiLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_tag_api_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TagApiLinkContract"]: + """Lists a collection of the API links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagApiLinkContract or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagApiLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TagApiLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Gets the API link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + parameters: _models.TagApiLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + parameters: Union[_models.TagApiLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Is either a TagApiLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract or IO[bytes] + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagApiLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified API from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operation_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operation_link_operations.py new file mode 100644 index 000000000000..be30993faebe --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operation_link_operations.py @@ -0,0 +1,498 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_tag_operation_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceTagOperationLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_tag_operation_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TagOperationLinkContract"]: + """Lists a collection of the operation links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| operationId + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagOperationLinkContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagOperationLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TagOperationLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Gets the operation link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagOperationLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + parameters: _models.TagOperationLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + parameters: Union[_models.TagOperationLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Is either a TagOperationLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract or IO[bytes] + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagOperationLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagOperationLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified operation from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operations.py new file mode 100644 index 000000000000..1de8f6e28d71 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operations.py @@ -0,0 +1,724 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_tag_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_entity_state_request, + build_get_request, + build_list_by_service_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceTagOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_tag` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + scope: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TagContract"]: + """Lists a collection of tags defined within a workspace in a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. + :type scope: str + :return: An iterator like instance of either TagContract or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TagCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_entity_state( + self, resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state version of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_state_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def get( + self, resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Gets the details of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + parameters: _models.TagCreateUpdateParameters, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagContract: + """Creates a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagContract: + """Creates a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + parameters: Union[_models.TagCreateUpdateParameters, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.TagContract: + """Creates a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Create parameters. Is either a TagCreateUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagCreateUpdateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + if_match: str, + parameters: _models.TagCreateUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagContract: + """Updates the details of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagContract: + """Updates the details of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + if_match: str, + parameters: Union[_models.TagCreateUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.TagContract: + """Updates the details of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a TagCreateUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or IO[bytes] + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagCreateUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, if_match: str, **kwargs: Any + ) -> None: + """Deletes specific tag of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_product_link_operations.py new file mode 100644 index 000000000000..9944464f358d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_product_link_operations.py @@ -0,0 +1,498 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._workspace_tag_product_link_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_product_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class WorkspaceTagProductLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`workspace_tag_product_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TagProductLinkContract"]: + """Lists a collection of the product links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| productId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagProductLinkContract or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagProductLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TagProductLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Gets the product link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagProductLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + parameters: _models.TagProductLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + parameters: Union[_models.TagProductLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Is either a TagProductLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract or IO[bytes] + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagProductLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagProductLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified product from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/__init__.py index 87d143776a42..9e8ef97fa777 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/__init__.py @@ -12,6 +12,8 @@ from ._models_py3 import AccessInformationSecretsContract from ._models_py3 import AccessInformationUpdateParameters from ._models_py3 import AdditionalLocation +from ._models_py3 import AllPoliciesCollection +from ._models_py3 import AllPoliciesContract from ._models_py3 import ApiCollection from ._models_py3 import ApiContactInformation from ._models_py3 import ApiContract @@ -24,6 +26,16 @@ from ._models_py3 import ApiExportResult from ._models_py3 import ApiExportResultValue from ._models_py3 import ApiLicenseInformation +from ._models_py3 import ApiManagementGatewayBaseProperties +from ._models_py3 import ApiManagementGatewayConfigConnectionListResult +from ._models_py3 import ApiManagementGatewayConfigConnectionResource +from ._models_py3 import ApiManagementGatewayListResult +from ._models_py3 import ApiManagementGatewayProperties +from ._models_py3 import ApiManagementGatewayResource +from ._models_py3 import ApiManagementGatewaySkuProperties +from ._models_py3 import ApiManagementGatewaySkuPropertiesForPatch +from ._models_py3 import ApiManagementGatewayUpdateParameters +from ._models_py3 import ApiManagementGatewayUpdateProperties from ._models_py3 import ApiManagementServiceApplyNetworkConfigurationParameters from ._models_py3 import ApiManagementServiceBackupRestoreParameters from ._models_py3 import ApiManagementServiceBaseProperties @@ -47,6 +59,9 @@ from ._models_py3 import ApiManagementSkuRestrictions from ._models_py3 import ApiManagementSkuZoneDetails from ._models_py3 import ApiManagementSkusResult +from ._models_py3 import ApiManagementWorkspaceLinksListResult +from ._models_py3 import ApiManagementWorkspaceLinksProperties +from ._models_py3 import ApiManagementWorkspaceLinksResource from ._models_py3 import ApiReleaseCollection from ._models_py3 import ApiReleaseContract from ._models_py3 import ApiRevisionCollection @@ -87,14 +102,20 @@ from ._models_py3 import AuthorizationServerUpdateContractProperties from ._models_py3 import BackendAuthorizationHeaderCredentials from ._models_py3 import BackendBaseParameters +from ._models_py3 import BackendBaseParametersPool +from ._models_py3 import BackendCircuitBreaker from ._models_py3 import BackendCollection +from ._models_py3 import BackendConfiguration from ._models_py3 import BackendContract from ._models_py3 import BackendContractProperties from ._models_py3 import BackendCredentialsContract +from ._models_py3 import BackendPool +from ._models_py3 import BackendPoolItem from ._models_py3 import BackendProperties from ._models_py3 import BackendProxyContract from ._models_py3 import BackendReconnectContract from ._models_py3 import BackendServiceFabricClusterProperties +from ._models_py3 import BackendSubnetConfiguration from ._models_py3 import BackendTlsProperties from ._models_py3 import BackendUpdateParameterProperties from ._models_py3 import BackendUpdateParameters @@ -107,7 +128,10 @@ from ._models_py3 import CertificateContract from ._models_py3 import CertificateCreateOrUpdateParameters from ._models_py3 import CertificateInformation +from ._models_py3 import CircuitBreakerFailureCondition +from ._models_py3 import CircuitBreakerRule from ._models_py3 import ClientSecretContract +from ._models_py3 import ConfigurationApi from ._models_py3 import ConnectivityCheckRequest from ._models_py3 import ConnectivityCheckRequestDestination from ._models_py3 import ConnectivityCheckRequestProtocolConfiguration @@ -128,6 +152,7 @@ from ._models_py3 import DeployConfigurationParameters from ._models_py3 import DiagnosticCollection from ._models_py3 import DiagnosticContract +from ._models_py3 import DiagnosticUpdateContract from ._models_py3 import DocumentationCollection from ._models_py3 import DocumentationContract from ._models_py3 import DocumentationUpdateContract @@ -137,17 +162,29 @@ from ._models_py3 import EmailTemplateUpdateParameters from ._models_py3 import EndpointDependency from ._models_py3 import EndpointDetail +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail from ._models_py3 import ErrorFieldContract from ._models_py3 import ErrorResponse from ._models_py3 import ErrorResponseBody +from ._models_py3 import FailureStatusCodeRange +from ._models_py3 import FrontendConfiguration from ._models_py3 import GatewayCertificateAuthorityCollection from ._models_py3 import GatewayCertificateAuthorityContract from ._models_py3 import GatewayCollection +from ._models_py3 import GatewayConfigurationApi from ._models_py3 import GatewayContract +from ._models_py3 import GatewayDebugCredentialsContract from ._models_py3 import GatewayHostnameConfigurationCollection from ._models_py3 import GatewayHostnameConfigurationContract from ._models_py3 import GatewayKeyRegenerationRequestContract from ._models_py3 import GatewayKeysContract +from ._models_py3 import GatewayListDebugCredentialsContract +from ._models_py3 import GatewayListTraceContract +from ._models_py3 import GatewayResourceSkuResult +from ._models_py3 import GatewayResourceSkuResults +from ._models_py3 import GatewaySku +from ._models_py3 import GatewaySkuCapacity from ._models_py3 import GatewayTokenContract from ._models_py3 import GatewayTokenRequestContract from ._models_py3 import GenerateSsoUrlResult @@ -185,6 +222,7 @@ from ._models_py3 import LoggerCollection from ._models_py3 import LoggerContract from ._models_py3 import LoggerUpdateContract +from ._models_py3 import MigrateToStv2Contract from ._models_py3 import NamedValueCollection from ._models_py3 import NamedValueContract from ._models_py3 import NamedValueContractProperties @@ -212,6 +250,7 @@ from ._models_py3 import OperationListResult from ._models_py3 import OperationResultContract from ._models_py3 import OperationResultLogItemContract +from ._models_py3 import OperationStatusResult from ._models_py3 import OperationTagResourceContractProperties from ._models_py3 import OperationUpdateContract from ._models_py3 import OperationUpdateContractProperties @@ -226,6 +265,11 @@ from ._models_py3 import PolicyDescriptionContract from ._models_py3 import PolicyFragmentCollection from ._models_py3 import PolicyFragmentContract +from ._models_py3 import PolicyRestrictionCollection +from ._models_py3 import PolicyRestrictionContract +from ._models_py3 import PolicyRestrictionUpdateContract +from ._models_py3 import PolicyWithComplianceCollection +from ._models_py3 import PolicyWithComplianceContract from ._models_py3 import PortalConfigCollection from ._models_py3 import PortalConfigContract from ._models_py3 import PortalConfigCorsProperties @@ -250,10 +294,14 @@ from ._models_py3 import PrivateLinkResource from ._models_py3 import PrivateLinkResourceListResult from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProductApiLinkCollection +from ._models_py3 import ProductApiLinkContract from ._models_py3 import ProductCollection from ._models_py3 import ProductContract from ._models_py3 import ProductContractProperties from ._models_py3 import ProductEntityBaseParameters +from ._models_py3 import ProductGroupLinkCollection +from ._models_py3 import ProductGroupLinkContract from ._models_py3 import ProductTagResourceContractProperties from ._models_py3 import ProductUpdateParameters from ._models_py3 import ProductUpdateProperties @@ -304,6 +352,8 @@ from ._models_py3 import SubscriptionUpdateParameters from ._models_py3 import SubscriptionsDelegationSettingsProperties from ._models_py3 import SystemData +from ._models_py3 import TagApiLinkCollection +from ._models_py3 import TagApiLinkContract from ._models_py3 import TagCollection from ._models_py3 import TagContract from ._models_py3 import TagCreateUpdateParameters @@ -312,6 +362,10 @@ from ._models_py3 import TagDescriptionContract from ._models_py3 import TagDescriptionContractProperties from ._models_py3 import TagDescriptionCreateParameters +from ._models_py3 import TagOperationLinkCollection +from ._models_py3 import TagOperationLinkContract +from ._models_py3 import TagProductLinkCollection +from ._models_py3 import TagProductLinkContract from ._models_py3 import TagResourceCollection from ._models_py3 import TagResourceContract from ._models_py3 import TagResourceContractProperties @@ -338,6 +392,10 @@ from ._models_py3 import WikiContract from ._models_py3 import WikiDocumentationContract from ._models_py3 import WikiUpdateContract +from ._models_py3 import WorkspaceCollection +from ._models_py3 import WorkspaceContract +from ._models_py3 import WorkspaceLinksBaseProperties +from ._models_py3 import WorkspaceLinksGateway from ._models_py3 import X509CertificateName from ._api_management_client_enums import AccessIdName @@ -354,6 +412,7 @@ from ._api_management_client_enums import AuthorizationMethod from ._api_management_client_enums import AuthorizationType from ._api_management_client_enums import BackendProtocol +from ._api_management_client_enums import BackendType from ._api_management_client_enums import BearerTokenSendingMethod from ._api_management_client_enums import BearerTokenSendingMethods from ._api_management_client_enums import CertificateConfigurationStoreName @@ -368,9 +427,12 @@ from ._api_management_client_enums import ContentFormat from ._api_management_client_enums import CreatedByType from ._api_management_client_enums import DataMaskingMode +from ._api_management_client_enums import DeveloperPortalStatus from ._api_management_client_enums import ExportApi from ._api_management_client_enums import ExportFormat from ._api_management_client_enums import ExportResultFormat +from ._api_management_client_enums import GatewayListDebugCredentialsContractPurpose +from ._api_management_client_enums import GatewaySkuCapacityScaleType from ._api_management_client_enums import GrantType from ._api_management_client_enums import GroupType from ._api_management_client_enums import HostnameType @@ -378,8 +440,12 @@ from ._api_management_client_enums import IdentityProviderType from ._api_management_client_enums import IssueType from ._api_management_client_enums import KeyType +from ._api_management_client_enums import KeyVaultRefreshState +from ._api_management_client_enums import LegacyApiState +from ._api_management_client_enums import LegacyPortalStatus from ._api_management_client_enums import LoggerType from ._api_management_client_enums import Method +from ._api_management_client_enums import MigrateToStv2Mode from ._api_management_client_enums import NameAvailabilityReason from ._api_management_client_enums import NatGatewayState from ._api_management_client_enums import NotificationName @@ -387,10 +453,12 @@ from ._api_management_client_enums import OperationNameFormat from ._api_management_client_enums import Origin from ._api_management_client_enums import PlatformVersion +from ._api_management_client_enums import PolicyComplianceState from ._api_management_client_enums import PolicyContentFormat from ._api_management_client_enums import PolicyExportFormat from ._api_management_client_enums import PolicyFragmentContentFormat from ._api_management_client_enums import PolicyIdName +from ._api_management_client_enums import PolicyRestrictionRequireBase from ._api_management_client_enums import PolicyScopeContract from ._api_management_client_enums import PortalRevisionStatus from ._api_management_client_enums import PortalSettingsCspMode @@ -399,6 +467,7 @@ from ._api_management_client_enums import PrivateEndpointServiceConnectionStatus from ._api_management_client_enums import ProductState from ._api_management_client_enums import Protocol +from ._api_management_client_enums import ProvisioningState from ._api_management_client_enums import PublicNetworkAccess from ._api_management_client_enums import ResourceSkuCapacityScaleType from ._api_management_client_enums import SamplingType @@ -426,6 +495,8 @@ "AccessInformationSecretsContract", "AccessInformationUpdateParameters", "AdditionalLocation", + "AllPoliciesCollection", + "AllPoliciesContract", "ApiCollection", "ApiContactInformation", "ApiContract", @@ -438,6 +509,16 @@ "ApiExportResult", "ApiExportResultValue", "ApiLicenseInformation", + "ApiManagementGatewayBaseProperties", + "ApiManagementGatewayConfigConnectionListResult", + "ApiManagementGatewayConfigConnectionResource", + "ApiManagementGatewayListResult", + "ApiManagementGatewayProperties", + "ApiManagementGatewayResource", + "ApiManagementGatewaySkuProperties", + "ApiManagementGatewaySkuPropertiesForPatch", + "ApiManagementGatewayUpdateParameters", + "ApiManagementGatewayUpdateProperties", "ApiManagementServiceApplyNetworkConfigurationParameters", "ApiManagementServiceBackupRestoreParameters", "ApiManagementServiceBaseProperties", @@ -461,6 +542,9 @@ "ApiManagementSkuRestrictions", "ApiManagementSkuZoneDetails", "ApiManagementSkusResult", + "ApiManagementWorkspaceLinksListResult", + "ApiManagementWorkspaceLinksProperties", + "ApiManagementWorkspaceLinksResource", "ApiReleaseCollection", "ApiReleaseContract", "ApiRevisionCollection", @@ -501,14 +585,20 @@ "AuthorizationServerUpdateContractProperties", "BackendAuthorizationHeaderCredentials", "BackendBaseParameters", + "BackendBaseParametersPool", + "BackendCircuitBreaker", "BackendCollection", + "BackendConfiguration", "BackendContract", "BackendContractProperties", "BackendCredentialsContract", + "BackendPool", + "BackendPoolItem", "BackendProperties", "BackendProxyContract", "BackendReconnectContract", "BackendServiceFabricClusterProperties", + "BackendSubnetConfiguration", "BackendTlsProperties", "BackendUpdateParameterProperties", "BackendUpdateParameters", @@ -521,7 +611,10 @@ "CertificateContract", "CertificateCreateOrUpdateParameters", "CertificateInformation", + "CircuitBreakerFailureCondition", + "CircuitBreakerRule", "ClientSecretContract", + "ConfigurationApi", "ConnectivityCheckRequest", "ConnectivityCheckRequestDestination", "ConnectivityCheckRequestProtocolConfiguration", @@ -542,6 +635,7 @@ "DeployConfigurationParameters", "DiagnosticCollection", "DiagnosticContract", + "DiagnosticUpdateContract", "DocumentationCollection", "DocumentationContract", "DocumentationUpdateContract", @@ -551,17 +645,29 @@ "EmailTemplateUpdateParameters", "EndpointDependency", "EndpointDetail", + "ErrorAdditionalInfo", + "ErrorDetail", "ErrorFieldContract", "ErrorResponse", "ErrorResponseBody", + "FailureStatusCodeRange", + "FrontendConfiguration", "GatewayCertificateAuthorityCollection", "GatewayCertificateAuthorityContract", "GatewayCollection", + "GatewayConfigurationApi", "GatewayContract", + "GatewayDebugCredentialsContract", "GatewayHostnameConfigurationCollection", "GatewayHostnameConfigurationContract", "GatewayKeyRegenerationRequestContract", "GatewayKeysContract", + "GatewayListDebugCredentialsContract", + "GatewayListTraceContract", + "GatewayResourceSkuResult", + "GatewayResourceSkuResults", + "GatewaySku", + "GatewaySkuCapacity", "GatewayTokenContract", "GatewayTokenRequestContract", "GenerateSsoUrlResult", @@ -599,6 +705,7 @@ "LoggerCollection", "LoggerContract", "LoggerUpdateContract", + "MigrateToStv2Contract", "NamedValueCollection", "NamedValueContract", "NamedValueContractProperties", @@ -626,6 +733,7 @@ "OperationListResult", "OperationResultContract", "OperationResultLogItemContract", + "OperationStatusResult", "OperationTagResourceContractProperties", "OperationUpdateContract", "OperationUpdateContractProperties", @@ -640,6 +748,11 @@ "PolicyDescriptionContract", "PolicyFragmentCollection", "PolicyFragmentContract", + "PolicyRestrictionCollection", + "PolicyRestrictionContract", + "PolicyRestrictionUpdateContract", + "PolicyWithComplianceCollection", + "PolicyWithComplianceContract", "PortalConfigCollection", "PortalConfigContract", "PortalConfigCorsProperties", @@ -664,10 +777,14 @@ "PrivateLinkResource", "PrivateLinkResourceListResult", "PrivateLinkServiceConnectionState", + "ProductApiLinkCollection", + "ProductApiLinkContract", "ProductCollection", "ProductContract", "ProductContractProperties", "ProductEntityBaseParameters", + "ProductGroupLinkCollection", + "ProductGroupLinkContract", "ProductTagResourceContractProperties", "ProductUpdateParameters", "ProductUpdateProperties", @@ -718,6 +835,8 @@ "SubscriptionUpdateParameters", "SubscriptionsDelegationSettingsProperties", "SystemData", + "TagApiLinkCollection", + "TagApiLinkContract", "TagCollection", "TagContract", "TagCreateUpdateParameters", @@ -726,6 +845,10 @@ "TagDescriptionContract", "TagDescriptionContractProperties", "TagDescriptionCreateParameters", + "TagOperationLinkCollection", + "TagOperationLinkContract", + "TagProductLinkCollection", + "TagProductLinkContract", "TagResourceCollection", "TagResourceContract", "TagResourceContractProperties", @@ -752,6 +875,10 @@ "WikiContract", "WikiDocumentationContract", "WikiUpdateContract", + "WorkspaceCollection", + "WorkspaceContract", + "WorkspaceLinksBaseProperties", + "WorkspaceLinksGateway", "X509CertificateName", "AccessIdName", "AccessType", @@ -767,6 +894,7 @@ "AuthorizationMethod", "AuthorizationType", "BackendProtocol", + "BackendType", "BearerTokenSendingMethod", "BearerTokenSendingMethods", "CertificateConfigurationStoreName", @@ -781,9 +909,12 @@ "ContentFormat", "CreatedByType", "DataMaskingMode", + "DeveloperPortalStatus", "ExportApi", "ExportFormat", "ExportResultFormat", + "GatewayListDebugCredentialsContractPurpose", + "GatewaySkuCapacityScaleType", "GrantType", "GroupType", "HostnameType", @@ -791,8 +922,12 @@ "IdentityProviderType", "IssueType", "KeyType", + "KeyVaultRefreshState", + "LegacyApiState", + "LegacyPortalStatus", "LoggerType", "Method", + "MigrateToStv2Mode", "NameAvailabilityReason", "NatGatewayState", "NotificationName", @@ -800,10 +935,12 @@ "OperationNameFormat", "Origin", "PlatformVersion", + "PolicyComplianceState", "PolicyContentFormat", "PolicyExportFormat", "PolicyFragmentContentFormat", "PolicyIdName", + "PolicyRestrictionRequireBase", "PolicyScopeContract", "PortalRevisionStatus", "PortalSettingsCspMode", @@ -812,6 +949,7 @@ "PrivateEndpointServiceConnectionStatus", "ProductState", "Protocol", + "ProvisioningState", "PublicNetworkAccess", "ResourceSkuCapacityScaleType", "SamplingType", diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py index 01c8f0ff131a..987f833b928d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py @@ -76,6 +76,8 @@ class ApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SOAP = "soap" WEBSOCKET = "websocket" GRAPHQL = "graphql" + ODATA = "odata" + GRPC = "grpc" class AppType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -134,6 +136,15 @@ class BackendProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Backend is a SOAP service.""" +class BackendType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the backend. A backend can be either Single or Pool.""" + + SINGLE = "Single" + """supports single backend""" + POOL = "Pool" + """supports pool backend""" + + class BearerTokenSendingMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """BearerTokenSendingMethod.""" @@ -228,7 +239,9 @@ class ConnectivityStatusType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Format of the Content in which the API is getting imported.""" + """Format of the Content in which the API is getting imported. New formats can be added in the + future. + """ WADL_XML = "wadl-xml" """The contents are inline and Content type is a WADL document.""" @@ -252,6 +265,14 @@ class ContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OpenAPI 3.0 JSON document is hosted on a publicly accessible internet address.""" GRAPHQL_LINK = "graphql-link" """The GraphQL API endpoint hosted on a publicly accessible internet address.""" + ODATA = "odata" + """The contents are inline and Content Type is a OData XML Document.""" + ODATA_LINK = "odata-link" + """The OData metadata document hosted on a publicly accessible internet address.""" + GRPC = "grpc" + """The contents are inline and Content Type is a gRPC protobuf file.""" + GRPC_LINK = "grpc-link" + """The gRPC protobuf file is hosted on a publicly accessible internet address.""" class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -272,6 +293,15 @@ class DataMaskingMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Hide the presence of an entity.""" +class DeveloperPortalStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of developer portal in this API Management service.""" + + ENABLED = "Enabled" + """Developer Portal is enabled for the service.""" + DISABLED = "Disabled" + """Developer Portal is disabled for the service.""" + + class ExportApi(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ExportApi.""" @@ -310,6 +340,24 @@ class ExportResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Export the API Definition in OpenAPI Specification 3.0 to Storage Blob.""" +class GatewayListDebugCredentialsContractPurpose(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Purpose of debug credential.""" + + TRACING = "tracing" + """The tracing purpose.""" + + +class GatewaySkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scale type applicable to the sku.""" + + AUTOMATIC = "Automatic" + """Supported scale type automatic.""" + MANUAL = "Manual" + """Supported scale type manual.""" + NONE = "None" + """Scaling not supported.""" + + class GrantType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """GrantType.""" @@ -340,6 +388,7 @@ class HostnameType(str, Enum, metaclass=CaseInsensitiveEnumMeta): MANAGEMENT = "Management" SCM = "Scm" DEVELOPER_PORTAL = "DeveloperPortal" + CONFIGURATION_API = "ConfigurationApi" class HttpCorrelationProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -392,6 +441,39 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SECONDARY = "secondary" +class KeyVaultRefreshState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KeyVaultRefreshState.""" + + TRUE = "true" + """Entities for which KeyVault refresh failed.""" + FALSE = "false" + """Entities for which KeyVault refresh succeeded""" + + +class LegacyApiState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indication whether or not the legacy Configuration API (v1) should be exposed on the API + Management service. Value is optional but must be 'Enabled' or 'Disabled'. If 'Disabled', + legacy Configuration API (v1) will not be available for self-hosted gateways. Default value is + 'Enabled'. + """ + + ENABLED = "Enabled" + """Legacy Configuration API (v1) is enabled for the service and self-hosted gateways can connect + to it.""" + DISABLED = "Disabled" + """Legacy Configuration API (v1) is disabled for the service and self-hosted gateways can not + connect to it.""" + + +class LegacyPortalStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of legacy portal in the API Management service.""" + + ENABLED = "Enabled" + """Legacy Portal is enabled for the service.""" + DISABLED = "Disabled" + """Legacy Portal is disabled for the service.""" + + class LoggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Logger type.""" @@ -410,6 +492,18 @@ class Method(str, Enum, metaclass=CaseInsensitiveEnumMeta): POST = "POST" +class MigrateToStv2Mode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Mode of Migration to stv2. Default is PreserveIp.""" + + PRESERVE_IP = "PreserveIp" + """Migrate API Management service to stv2 from stv1, by reserving the IP Address of the service. + This will have a downtime of upto 15 minutes, while the IP address is getting migrate to new + infrastructure.""" + NEW_IP = "NewIP" + """Migrate API Management service to stv2 from stv1. This will have no downtime as the service + configuration will be migrated to new infrastructure, but the IP address will changed.""" + + class NameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invalid indicates the name provided does not match the resource provider’s naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is @@ -492,6 +586,19 @@ class PlatformVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Platform running the service on Single Tenant V2 platform.""" MTV1 = "mtv1" """Platform running the service on Multi Tenant V1 platform.""" + STV2_1 = "stv2.1" + """Platform running the service on Single Tenant V2 platform on newer Hardware.""" + + +class PolicyComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Policy Restriction Compliance State.""" + + PENDING = "Pending" + """The policy restriction compliance state has not yet been determined.""" + NON_COMPLIANT = "NonCompliant" + """The scope in restriction is out of compliance.""" + COMPLIANT = "Compliant" + """The scope in restriction is in compliance.""" class PolicyContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -533,6 +640,15 @@ class PolicyIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): POLICY = "policy" +class PolicyRestrictionRequireBase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if base policy should be enforced for the policy document.""" + + TRUE = "true" + """The policy is required to have base policy""" + FALSE = "false" + """The policy does not require to have base policy""" + + class PolicyScopeContract(str, Enum, metaclass=CaseInsensitiveEnumMeta): """PolicyScopeContract.""" @@ -609,6 +725,19 @@ class Protocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): WSS = "wss" +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state of the API Management gateway config connection.""" + + ACTIVATING = "Activating" + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + TERMINATING = "Terminating" + UPGRADING = "Upgrading" + UPDATING = "Updating" + CREATED = "created" + + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints @@ -662,18 +791,12 @@ class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): class SkuType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the Sku.""" - DEVELOPER = "Developer" - """Developer SKU of Api Management.""" STANDARD = "Standard" - """Standard SKU of Api Management.""" - PREMIUM = "Premium" - """Premium SKU of Api Management.""" - BASIC = "Basic" - """Basic SKU of Api Management.""" - CONSUMPTION = "Consumption" - """Consumption SKU of Api Management.""" - ISOLATED = "Isolated" - """Isolated SKU of Api Management.""" + """Standard SKU of the API gateway.""" + WORKSPACE_GATEWAY_STANDARD = "WorkspaceGatewayStandard" + """Standard SKU of the API gateway to be used in Workspaces.""" + WORKSPACE_GATEWAY_PREMIUM = "WorkspaceGatewayPremium" + """Premium SKU of the API gateway to be used in Workspaces.""" class SoapApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -684,6 +807,7 @@ class SoapApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API * ``graphql`` creates GraphQL API. + New types can be added in the future. """ SOAP_TO_REST = "http" @@ -694,6 +818,10 @@ class SoapApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Imports the API having a Websocket front end.""" GRAPH_QL = "graphql" """Imports the API having a GraphQL front end.""" + O_DATA = "odata" + """Imports the API having a OData front end.""" + G_RPC = "grpc" + """Imports the API having a gRPC front end.""" class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -799,17 +927,12 @@ class VersioningScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): class VirtualNetworkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of VPN in which API Management service needs to be configured in. None (Default Value) - means the API Management service is not part of any Virtual Network, External means the API - Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, - and Internal means that API Management deployment is setup inside a Virtual Network having an - Intranet Facing Endpoint only. - """ + """The type of VPN in which API Management gateway needs to be configured in.""" NONE = "None" - """The service is not part of any Virtual Network.""" + """The API Management gateway is not part of any Virtual Network.""" EXTERNAL = "External" - """The service is part of Virtual Network and it is accessible from Internet.""" + """The API Management gateway is part of Virtual Network and it is accessible from Internet.""" INTERNAL = "Internal" - """The service is part of Virtual Network and it is only accessible from within the virtual - network.""" + """The API Management gateway is part of Virtual Network and it is only accessible from within the + virtual network.""" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py index 6c4770ae7729..40d23e7caa8e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py @@ -9,7 +9,7 @@ import datetime import sys -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization @@ -337,7 +337,7 @@ class AdditionalLocation(_serialization.Model): # pylint: disable=too-many-inst locations. This can be used to disable the gateway in this additional location. :vartype disable_gateway: bool :ivar platform_version: Compute Platform Version running the service. Known values are: - "undetermined", "stv1", "stv2", and "mtv1". + "undetermined", "stv1", "stv2", "mtv1", and "stv2.1". :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion """ @@ -415,6 +415,91 @@ def __init__( self.platform_version = None +class AllPoliciesCollection(_serialization.Model): + """The response of All Policies. + + :ivar value: AllPolicies Contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.AllPoliciesContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AllPoliciesContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AllPoliciesContract"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: AllPolicies Contract value. + :paramtype value: list[~azure.mgmt.apimanagement.models.AllPoliciesContract] + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AllPoliciesContract(ProxyResource): + """AllPolicies Contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar reference_policy_id: Policy Identifier. + :vartype reference_policy_id: str + :ivar compliance_state: Policy Restriction Compliance State. Known values are: "Pending", + "NonCompliant", and "Compliant". + :vartype compliance_state: str or ~azure.mgmt.apimanagement.models.PolicyComplianceState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "reference_policy_id": {"key": "properties.referencePolicyId", "type": "str"}, + "compliance_state": {"key": "properties.complianceState", "type": "str"}, + } + + def __init__( + self, + *, + reference_policy_id: Optional[str] = None, + compliance_state: Optional[Union[str, "_models.PolicyComplianceState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword reference_policy_id: Policy Identifier. + :paramtype reference_policy_id: str + :keyword compliance_state: Policy Restriction Compliance State. Known values are: "Pending", + "NonCompliant", and "Compliant". + :paramtype compliance_state: str or ~azure.mgmt.apimanagement.models.PolicyComplianceState + """ + super().__init__(**kwargs) + self.reference_policy_id = reference_policy_id + self.compliance_state = compliance_state + + class ApiCollection(_serialization.Model): """Paged API list representation. @@ -507,7 +592,8 @@ class ApiContract(ProxyResource): # pylint: disable=too-many-instance-attribute :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", "odata", + and "grpc". :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -549,6 +635,8 @@ class ApiContract(ProxyResource): # pylint: disable=too-many-instance-attribute :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _validation = { @@ -563,6 +651,7 @@ class ApiContract(ProxyResource): # pylint: disable=too-many-instance-attribute "display_name": {"max_length": 300, "min_length": 1}, "service_url": {"max_length": 2000}, "path": {"max_length": 400}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -596,6 +685,7 @@ class ApiContract(ProxyResource): # pylint: disable=too-many-instance-attribute "path": {"key": "properties.path", "type": "str"}, "protocols": {"key": "properties.protocols", "type": "[str]"}, "api_version_set": {"key": "properties.apiVersionSet", "type": "ApiVersionSetContractDetails"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( # pylint: disable=too-many-locals @@ -632,7 +722,8 @@ def __init__( # pylint: disable=too-many-locals :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", + "odata", and "grpc". :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -695,6 +786,7 @@ def __init__( # pylint: disable=too-many-locals self.path = path self.protocols = protocols self.api_version_set = api_version_set + self.provisioning_state = None class ApiEntityBaseContract(_serialization.Model): # pylint: disable=too-many-instance-attributes @@ -710,7 +802,8 @@ class ApiEntityBaseContract(_serialization.Model): # pylint: disable=too-many-i :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", "odata", + and "grpc". :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -796,7 +889,8 @@ def __init__( :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", + "odata", and "grpc". :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -855,7 +949,8 @@ class ApiContractProperties(ApiEntityBaseContract): # pylint: disable=too-many- :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", "odata", + and "grpc". :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -897,6 +992,8 @@ class ApiContractProperties(ApiEntityBaseContract): # pylint: disable=too-many- :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _validation = { @@ -908,6 +1005,7 @@ class ApiContractProperties(ApiEntityBaseContract): # pylint: disable=too-many- "display_name": {"max_length": 300, "min_length": 1}, "service_url": {"max_length": 2000}, "path": {"required": True, "max_length": 400}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -935,6 +1033,7 @@ class ApiContractProperties(ApiEntityBaseContract): # pylint: disable=too-many- "path": {"key": "path", "type": "str"}, "protocols": {"key": "protocols", "type": "[str]"}, "api_version_set": {"key": "apiVersionSet", "type": "ApiVersionSetContractDetails"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -971,7 +1070,8 @@ def __init__( :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", + "odata", and "grpc". :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -1035,6 +1135,7 @@ def __init__( self.path = path self.protocols = protocols self.api_version_set = api_version_set + self.provisioning_state = None class ApiContractUpdateProperties(ApiEntityBaseContract): # pylint: disable=too-many-instance-attributes @@ -1050,7 +1151,8 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): # pylint: disable=too :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", "odata", + and "grpc". :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -1157,7 +1259,8 @@ def __init__( :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", + "odata", and "grpc". :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -1229,7 +1332,8 @@ class ApiCreateOrUpdateParameter(_serialization.Model): # pylint: disable=too-m :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", "odata", + and "grpc". :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -1271,11 +1375,14 @@ class ApiCreateOrUpdateParameter(_serialization.Model): # pylint: disable=too-m :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str :ivar value: Content value when Importing an API. :vartype value: str - :ivar format: Format of the Content in which the API is getting imported. Known values are: - "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", - "openapi", "openapi+json", "openapi-link", "openapi+json-link", and "graphql-link". + :ivar format: Format of the Content in which the API is getting imported. New formats can be + added in the future. Known values are: "wadl-xml", "wadl-link-json", "swagger-json", + "swagger-link-json", "wsdl", "wsdl-link", "openapi", "openapi+json", "openapi-link", + "openapi+json-link", "graphql-link", "odata", "odata-link", "grpc", and "grpc-link". :vartype format: str or ~azure.mgmt.apimanagement.models.ContentFormat :ivar wsdl_selector: Criteria to limit import of WSDL to a subset of the document. :vartype wsdl_selector: @@ -1286,8 +1393,9 @@ class ApiCreateOrUpdateParameter(_serialization.Model): # pylint: disable=too-m * ``http`` creates a REST API * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", and - "graphql". + * ``graphql`` creates GraphQL API. + New types can be added in the future. Known values are: "http", "soap", "websocket", + "graphql", "odata", and "grpc". :vartype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType :ivar translate_required_query_parameters_conduct: Strategy of translating required query parameters to template ones. By default has value 'template'. Possible values: 'template', @@ -1305,6 +1413,7 @@ class ApiCreateOrUpdateParameter(_serialization.Model): # pylint: disable=too-m "display_name": {"max_length": 300, "min_length": 1}, "service_url": {"max_length": 2000}, "path": {"max_length": 400}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -1335,6 +1444,7 @@ class ApiCreateOrUpdateParameter(_serialization.Model): # pylint: disable=too-m "path": {"key": "properties.path", "type": "str"}, "protocols": {"key": "properties.protocols", "type": "[str]"}, "api_version_set": {"key": "properties.apiVersionSet", "type": "ApiVersionSetContractDetails"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "value": {"key": "properties.value", "type": "str"}, "format": {"key": "properties.format", "type": "str"}, "wsdl_selector": {"key": "properties.wsdlSelector", "type": "ApiCreateOrUpdatePropertiesWsdlSelector"}, @@ -1386,7 +1496,8 @@ def __init__( # pylint: disable=too-many-locals :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", + "odata", and "grpc". :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -1428,9 +1539,10 @@ def __init__( # pylint: disable=too-many-locals :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :keyword value: Content value when Importing an API. :paramtype value: str - :keyword format: Format of the Content in which the API is getting imported. Known values are: - "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", - "openapi", "openapi+json", "openapi-link", "openapi+json-link", and "graphql-link". + :keyword format: Format of the Content in which the API is getting imported. New formats can be + added in the future. Known values are: "wadl-xml", "wadl-link-json", "swagger-json", + "swagger-link-json", "wsdl", "wsdl-link", "openapi", "openapi+json", "openapi-link", + "openapi+json-link", "graphql-link", "odata", "odata-link", "grpc", and "grpc-link". :paramtype format: str or ~azure.mgmt.apimanagement.models.ContentFormat :keyword wsdl_selector: Criteria to limit import of WSDL to a subset of the document. :paramtype wsdl_selector: @@ -1441,8 +1553,9 @@ def __init__( # pylint: disable=too-many-locals * ``http`` creates a REST API * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", and - "graphql". + * ``graphql`` creates GraphQL API. + New types can be added in the future. Known values are: "http", "soap", "websocket", + "graphql", "odata", and "grpc". :paramtype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType :keyword translate_required_query_parameters_conduct: Strategy of translating required query parameters to template ones. By default has value 'template'. Possible values: 'template', @@ -1472,6 +1585,7 @@ def __init__( # pylint: disable=too-many-locals self.path = path self.protocols = protocols self.api_version_set = api_version_set + self.provisioning_state = None self.value = value self.format = format self.wsdl_selector = wsdl_selector @@ -1494,7 +1608,8 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): # pylint: disable=too :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", "odata", + and "grpc". :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -1536,11 +1651,14 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): # pylint: disable=too :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str :ivar value: Content value when Importing an API. :vartype value: str - :ivar format: Format of the Content in which the API is getting imported. Known values are: - "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", - "openapi", "openapi+json", "openapi-link", "openapi+json-link", and "graphql-link". + :ivar format: Format of the Content in which the API is getting imported. New formats can be + added in the future. Known values are: "wadl-xml", "wadl-link-json", "swagger-json", + "swagger-link-json", "wsdl", "wsdl-link", "openapi", "openapi+json", "openapi-link", + "openapi+json-link", "graphql-link", "odata", "odata-link", "grpc", and "grpc-link". :vartype format: str or ~azure.mgmt.apimanagement.models.ContentFormat :ivar wsdl_selector: Criteria to limit import of WSDL to a subset of the document. :vartype wsdl_selector: @@ -1551,8 +1669,9 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): # pylint: disable=too * ``http`` creates a REST API * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", and - "graphql". + * ``graphql`` creates GraphQL API. + New types can be added in the future. Known values are: "http", "soap", "websocket", + "graphql", "odata", and "grpc". :vartype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType :ivar translate_required_query_parameters_conduct: Strategy of translating required query parameters to template ones. By default has value 'template'. Possible values: 'template', @@ -1570,6 +1689,7 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): # pylint: disable=too "display_name": {"max_length": 300, "min_length": 1}, "service_url": {"max_length": 2000}, "path": {"required": True, "max_length": 400}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -1597,6 +1717,7 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): # pylint: disable=too "path": {"key": "path", "type": "str"}, "protocols": {"key": "protocols", "type": "[str]"}, "api_version_set": {"key": "apiVersionSet", "type": "ApiVersionSetContractDetails"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, "value": {"key": "value", "type": "str"}, "format": {"key": "format", "type": "str"}, "wsdl_selector": {"key": "wsdlSelector", "type": "ApiCreateOrUpdatePropertiesWsdlSelector"}, @@ -1645,7 +1766,8 @@ def __init__( # pylint: disable=too-many-locals :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", + "odata", and "grpc". :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -1687,9 +1809,10 @@ def __init__( # pylint: disable=too-many-locals :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :keyword value: Content value when Importing an API. :paramtype value: str - :keyword format: Format of the Content in which the API is getting imported. Known values are: - "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", - "openapi", "openapi+json", "openapi-link", "openapi+json-link", and "graphql-link". + :keyword format: Format of the Content in which the API is getting imported. New formats can be + added in the future. Known values are: "wadl-xml", "wadl-link-json", "swagger-json", + "swagger-link-json", "wsdl", "wsdl-link", "openapi", "openapi+json", "openapi-link", + "openapi+json-link", "graphql-link", "odata", "odata-link", "grpc", and "grpc-link". :paramtype format: str or ~azure.mgmt.apimanagement.models.ContentFormat :keyword wsdl_selector: Criteria to limit import of WSDL to a subset of the document. :paramtype wsdl_selector: @@ -1700,8 +1823,9 @@ def __init__( # pylint: disable=too-many-locals * ``http`` creates a REST API * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", and - "graphql". + * ``graphql`` creates GraphQL API. + New types can be added in the future. Known values are: "http", "soap", "websocket", + "graphql", "odata", and "grpc". :paramtype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType :keyword translate_required_query_parameters_conduct: Strategy of translating required query parameters to template ones. By default has value 'template'. Possible values: 'template', @@ -1858,114 +1982,716 @@ def __init__(self, *, name: Optional[str] = None, url: Optional[str] = None, **k self.url = url -class ApiManagementServiceApplyNetworkConfigurationParameters(_serialization.Model): # pylint: disable=name-too-long - """Parameter supplied to the Apply Network configuration operation. +class ApiManagementGatewayBaseProperties(_serialization.Model): + """Base Properties of an API Management gateway resource description. - :ivar location: Location of the Api Management service to update for a multi-region service. - For a service deployed in a single region, this parameter is not required. - :vartype location: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The current provisioning state of the API Management gateway which + can be one of the following: + Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + :vartype provisioning_state: str + :ivar target_provisioning_state: The provisioning state of the API Management gateway, which is + targeted by the long running operation started on the gateway. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management gateway.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime + :ivar frontend: Information regarding how the gateway should be exposed. + :vartype frontend: ~azure.mgmt.apimanagement.models.FrontendConfiguration + :ivar backend: Information regarding how the gateway should integrate with backend systems. + :vartype backend: ~azure.mgmt.apimanagement.models.BackendConfiguration + :ivar configuration_api: Information regarding the Configuration API of the API Management + gateway. This is only applicable for API gateway with Standard SKU. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.GatewayConfigurationApi + :ivar virtual_network_type: The type of VPN in which API Management gateway needs to be + configured in. Known values are: "None", "External", and "Internal". + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType """ + _validation = { + "provisioning_state": {"readonly": True}, + "target_provisioning_state": {"readonly": True}, + "created_at_utc": {"readonly": True}, + } + _attribute_map = { - "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "target_provisioning_state": {"key": "targetProvisioningState", "type": "str"}, + "created_at_utc": {"key": "createdAtUtc", "type": "iso-8601"}, + "frontend": {"key": "frontend", "type": "FrontendConfiguration"}, + "backend": {"key": "backend", "type": "BackendConfiguration"}, + "configuration_api": {"key": "configurationApi", "type": "GatewayConfigurationApi"}, + "virtual_network_type": {"key": "virtualNetworkType", "type": "str"}, } - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + frontend: Optional["_models.FrontendConfiguration"] = None, + backend: Optional["_models.BackendConfiguration"] = None, + configuration_api: Optional["_models.GatewayConfigurationApi"] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, + **kwargs: Any + ) -> None: """ - :keyword location: Location of the Api Management service to update for a multi-region service. - For a service deployed in a single region, this parameter is not required. - :paramtype location: str + :keyword frontend: Information regarding how the gateway should be exposed. + :paramtype frontend: ~azure.mgmt.apimanagement.models.FrontendConfiguration + :keyword backend: Information regarding how the gateway should integrate with backend systems. + :paramtype backend: ~azure.mgmt.apimanagement.models.BackendConfiguration + :keyword configuration_api: Information regarding the Configuration API of the API Management + gateway. This is only applicable for API gateway with Standard SKU. + :paramtype configuration_api: ~azure.mgmt.apimanagement.models.GatewayConfigurationApi + :keyword virtual_network_type: The type of VPN in which API Management gateway needs to be + configured in. Known values are: "None", "External", and "Internal". + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType """ super().__init__(**kwargs) - self.location = location + self.provisioning_state = None + self.target_provisioning_state = None + self.created_at_utc = None + self.frontend = frontend + self.backend = backend + self.configuration_api = configuration_api + self.virtual_network_type = virtual_network_type -class ApiManagementServiceBackupRestoreParameters(_serialization.Model): # pylint: disable=name-too-long - """Parameters supplied to the Backup/Restore of an API Management service operation. +class ApiManagementGatewayConfigConnectionListResult(_serialization.Model): # pylint: disable=name-too-long + """The response of the List API Management gateway operation. All required parameters must be populated in order to send to server. - :ivar storage_account: The name of the Azure storage account (used to place/retrieve the - backup). Required. - :vartype storage_account: str - :ivar container_name: The name of the blob container (used to place/retrieve the backup). - Required. - :vartype container_name: str - :ivar backup_name: The name of the backup file to create/retrieve. Required. - :vartype backup_name: str - :ivar access_type: The type of access to be used for the storage account. Known values are: - "AccessKey", "SystemAssignedManagedIdentity", and "UserAssignedManagedIdentity". - :vartype access_type: str or ~azure.mgmt.apimanagement.models.AccessType - :ivar access_key: Storage account access key. Required only if ``accessType`` is set to - ``AccessKey``. - :vartype access_key: str - :ivar client_id: The Client ID of user assigned managed identity. Required only if - ``accessType`` is set to ``UserAssignedManagedIdentity``. - :vartype client_id: str + :ivar value: Result of the List API Management gateway config connection operation. Required. + :vartype value: + list[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list + of API Management services. + :vartype next_link: str """ _validation = { - "storage_account": {"required": True}, - "container_name": {"required": True}, - "backup_name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - "storage_account": {"key": "storageAccount", "type": "str"}, - "container_name": {"key": "containerName", "type": "str"}, - "backup_name": {"key": "backupName", "type": "str"}, - "access_type": {"key": "accessType", "type": "str"}, - "access_key": {"key": "accessKey", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, + "value": {"key": "value", "type": "[ApiManagementGatewayConfigConnectionResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - storage_account: str, - container_name: str, - backup_name: str, - access_type: Union[str, "_models.AccessType"] = "AccessKey", - access_key: Optional[str] = None, - client_id: Optional[str] = None, + value: List["_models.ApiManagementGatewayConfigConnectionResource"], + next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword storage_account: The name of the Azure storage account (used to place/retrieve the - backup). Required. - :paramtype storage_account: str - :keyword container_name: The name of the blob container (used to place/retrieve the backup). + :keyword value: Result of the List API Management gateway config connection operation. Required. - :paramtype container_name: str - :keyword backup_name: The name of the backup file to create/retrieve. Required. - :paramtype backup_name: str - :keyword access_type: The type of access to be used for the storage account. Known values are: - "AccessKey", "SystemAssignedManagedIdentity", and "UserAssignedManagedIdentity". - :paramtype access_type: str or ~azure.mgmt.apimanagement.models.AccessType - :keyword access_key: Storage account access key. Required only if ``accessType`` is set to - ``AccessKey``. - :paramtype access_key: str - :keyword client_id: The Client ID of user assigned managed identity. Required only if - ``accessType`` is set to ``UserAssignedManagedIdentity``. - :paramtype client_id: str + :paramtype value: + list[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of API Management services. + :paramtype next_link: str """ super().__init__(**kwargs) - self.storage_account = storage_account - self.container_name = container_name - self.backup_name = backup_name - self.access_type = access_type - self.access_key = access_key - self.client_id = client_id + self.value = value + self.next_link = next_link -class ApiManagementServiceBaseProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Base Properties of an API Management service resource description. +class ApiManagementGatewayConfigConnectionResource(ProxyResource): # pylint: disable=name-too-long + """A single API Management gateway resource in List or Get response. Variables are only populated by the server, and will be ignored when sending a request. - :ivar notification_sender_email: Email address from which the notification will be sent. - :vartype notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API Management service which + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: ETag of the resource. + :vartype etag: str + :ivar provisioning_state: The current provisioning state of the API Management gateway config + connection. Known values are: "Activating", "Canceled", "Failed", "Succeeded", "Terminating", + "Upgrading", "Updating", and "created". + :vartype provisioning_state: str or ~azure.mgmt.apimanagement.models.ProvisioningState + :ivar source_id: The link to the API Management service workspace. + :vartype source_id: str + :ivar default_hostname: The default hostname of the data-plane gateway. + :vartype default_hostname: str + :ivar hostnames: The hostnames of the data-plane gateway to which requests can be sent. + :vartype hostnames: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "default_hostname": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "source_id": {"key": "properties.sourceId", "type": "str"}, + "default_hostname": {"key": "properties.defaultHostname", "type": "str"}, + "hostnames": {"key": "properties.hostnames", "type": "[str]"}, + } + + def __init__( + self, *, source_id: Optional[str] = None, hostnames: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """ + :keyword source_id: The link to the API Management service workspace. + :paramtype source_id: str + :keyword hostnames: The hostnames of the data-plane gateway to which requests can be sent. + :paramtype hostnames: list[str] + """ + super().__init__(**kwargs) + self.etag = None + self.provisioning_state = None + self.source_id = source_id + self.default_hostname = None + self.hostnames = hostnames + + +class ApiManagementGatewayListResult(_serialization.Model): + """The response of the List API Management gateway operation. + + All required parameters must be populated in order to send to server. + + :ivar value: Result of the List API Management gateway operation. Required. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list + of API Management services. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApiManagementGatewayResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.ApiManagementGatewayResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Result of the List API Management gateway operation. Required. + :paramtype value: list[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of API Management services. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApiManagementGatewayProperties(ApiManagementGatewayBaseProperties): + """Properties of an API Management gateway resource description. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The current provisioning state of the API Management gateway which + can be one of the following: + Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + :vartype provisioning_state: str + :ivar target_provisioning_state: The provisioning state of the API Management gateway, which is + targeted by the long running operation started on the gateway. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management gateway.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime + :ivar frontend: Information regarding how the gateway should be exposed. + :vartype frontend: ~azure.mgmt.apimanagement.models.FrontendConfiguration + :ivar backend: Information regarding how the gateway should integrate with backend systems. + :vartype backend: ~azure.mgmt.apimanagement.models.BackendConfiguration + :ivar configuration_api: Information regarding the Configuration API of the API Management + gateway. This is only applicable for API gateway with Standard SKU. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.GatewayConfigurationApi + :ivar virtual_network_type: The type of VPN in which API Management gateway needs to be + configured in. Known values are: "None", "External", and "Internal". + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + """ + + +class ApimResource(_serialization.Model): + """The Resource definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = tags + + +class ApiManagementGatewayResource(ApimResource): # pylint: disable=too-many-instance-attributes + """A single API Management gateway resource in List or Get response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar sku: SKU properties of the API Management gateway. Required. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementGatewaySkuProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar location: Resource location. Required. + :vartype location: str + :ivar etag: ETag of the resource. + :vartype etag: str + :ivar provisioning_state: The current provisioning state of the API Management gateway which + can be one of the following: + Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + :vartype provisioning_state: str + :ivar target_provisioning_state: The provisioning state of the API Management gateway, which is + targeted by the long running operation started on the gateway. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management gateway.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime + :ivar frontend: Information regarding how the gateway should be exposed. + :vartype frontend: ~azure.mgmt.apimanagement.models.FrontendConfiguration + :ivar backend: Information regarding how the gateway should integrate with backend systems. + :vartype backend: ~azure.mgmt.apimanagement.models.BackendConfiguration + :ivar configuration_api: Information regarding the Configuration API of the API Management + gateway. This is only applicable for API gateway with Standard SKU. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.GatewayConfigurationApi + :ivar virtual_network_type: The type of VPN in which API Management gateway needs to be + configured in. Known values are: "None", "External", and "Internal". + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"required": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "etag": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "target_provisioning_state": {"readonly": True}, + "created_at_utc": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "ApiManagementGatewaySkuProperties"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "target_provisioning_state": {"key": "properties.targetProvisioningState", "type": "str"}, + "created_at_utc": {"key": "properties.createdAtUtc", "type": "iso-8601"}, + "frontend": {"key": "properties.frontend", "type": "FrontendConfiguration"}, + "backend": {"key": "properties.backend", "type": "BackendConfiguration"}, + "configuration_api": {"key": "properties.configurationApi", "type": "GatewayConfigurationApi"}, + "virtual_network_type": {"key": "properties.virtualNetworkType", "type": "str"}, + } + + def __init__( + self, + *, + sku: "_models.ApiManagementGatewaySkuProperties", + location: str, + tags: Optional[Dict[str, str]] = None, + frontend: Optional["_models.FrontendConfiguration"] = None, + backend: Optional["_models.BackendConfiguration"] = None, + configuration_api: Optional["_models.GatewayConfigurationApi"] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: SKU properties of the API Management gateway. Required. + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementGatewaySkuProperties + :keyword location: Resource location. Required. + :paramtype location: str + :keyword frontend: Information regarding how the gateway should be exposed. + :paramtype frontend: ~azure.mgmt.apimanagement.models.FrontendConfiguration + :keyword backend: Information regarding how the gateway should integrate with backend systems. + :paramtype backend: ~azure.mgmt.apimanagement.models.BackendConfiguration + :keyword configuration_api: Information regarding the Configuration API of the API Management + gateway. This is only applicable for API gateway with Standard SKU. + :paramtype configuration_api: ~azure.mgmt.apimanagement.models.GatewayConfigurationApi + :keyword virtual_network_type: The type of VPN in which API Management gateway needs to be + configured in. Known values are: "None", "External", and "Internal". + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + """ + super().__init__(tags=tags, **kwargs) + self.sku = sku + self.system_data = None + self.location = location + self.etag = None + self.provisioning_state = None + self.target_provisioning_state = None + self.created_at_utc = None + self.frontend = frontend + self.backend = backend + self.configuration_api = configuration_api + self.virtual_network_type = virtual_network_type + + +class ApiManagementGatewaySkuProperties(_serialization.Model): + """API Management gateway resource SKU properties. + + All required parameters must be populated in order to send to server. + + :ivar name: Name of the Sku. Required. Known values are: "Standard", + "WorkspaceGatewayStandard", and "WorkspaceGatewayPremium". + :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType + :ivar capacity: Capacity of the SKU (number of deployed units of the SKU). + :vartype capacity: int + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + } + + def __init__(self, *, name: Union[str, "_models.SkuType"], capacity: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the Sku. Required. Known values are: "Standard", + "WorkspaceGatewayStandard", and "WorkspaceGatewayPremium". + :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType + :keyword capacity: Capacity of the SKU (number of deployed units of the SKU). + :paramtype capacity: int + """ + super().__init__(**kwargs) + self.name = name + self.capacity = capacity + + +class ApiManagementGatewaySkuPropertiesForPatch(_serialization.Model): # pylint: disable=name-too-long + """API Management gateway resource SKU properties for PATCH operations given nothing should be + required. + + :ivar name: Name of the Sku. Known values are: "Standard", "WorkspaceGatewayStandard", and + "WorkspaceGatewayPremium". + :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType + :ivar capacity: Capacity of the SKU (number of deployed units of the SKU). + :vartype capacity: int + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + } + + def __init__( + self, *, name: Optional[Union[str, "_models.SkuType"]] = None, capacity: Optional[int] = None, **kwargs: Any + ) -> None: + """ + :keyword name: Name of the Sku. Known values are: "Standard", "WorkspaceGatewayStandard", and + "WorkspaceGatewayPremium". + :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType + :keyword capacity: Capacity of the SKU (number of deployed units of the SKU). + :paramtype capacity: int + """ + super().__init__(**kwargs) + self.name = name + self.capacity = capacity + + +class ApiManagementGatewayUpdateParameters(ApimResource): # pylint: disable=too-many-instance-attributes + """Parameter supplied to Update API Management gateway. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar sku: SKU properties of the API Management gateway. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementGatewaySkuPropertiesForPatch + :ivar etag: ETag of the resource. + :vartype etag: str + :ivar provisioning_state: The current provisioning state of the API Management gateway which + can be one of the following: + Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + :vartype provisioning_state: str + :ivar target_provisioning_state: The provisioning state of the API Management gateway, which is + targeted by the long running operation started on the gateway. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management gateway.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime + :ivar frontend: Information regarding how the gateway should be exposed. + :vartype frontend: ~azure.mgmt.apimanagement.models.FrontendConfiguration + :ivar backend: Information regarding how the gateway should integrate with backend systems. + :vartype backend: ~azure.mgmt.apimanagement.models.BackendConfiguration + :ivar configuration_api: Information regarding the Configuration API of the API Management + gateway. This is only applicable for API gateway with Standard SKU. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.GatewayConfigurationApi + :ivar virtual_network_type: The type of VPN in which API Management gateway needs to be + configured in. Known values are: "None", "External", and "Internal". + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "target_provisioning_state": {"readonly": True}, + "created_at_utc": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "ApiManagementGatewaySkuPropertiesForPatch"}, + "etag": {"key": "etag", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "target_provisioning_state": {"key": "properties.targetProvisioningState", "type": "str"}, + "created_at_utc": {"key": "properties.createdAtUtc", "type": "iso-8601"}, + "frontend": {"key": "properties.frontend", "type": "FrontendConfiguration"}, + "backend": {"key": "properties.backend", "type": "BackendConfiguration"}, + "configuration_api": {"key": "properties.configurationApi", "type": "GatewayConfigurationApi"}, + "virtual_network_type": {"key": "properties.virtualNetworkType", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.ApiManagementGatewaySkuPropertiesForPatch"] = None, + frontend: Optional["_models.FrontendConfiguration"] = None, + backend: Optional["_models.BackendConfiguration"] = None, + configuration_api: Optional["_models.GatewayConfigurationApi"] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: SKU properties of the API Management gateway. + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementGatewaySkuPropertiesForPatch + :keyword frontend: Information regarding how the gateway should be exposed. + :paramtype frontend: ~azure.mgmt.apimanagement.models.FrontendConfiguration + :keyword backend: Information regarding how the gateway should integrate with backend systems. + :paramtype backend: ~azure.mgmt.apimanagement.models.BackendConfiguration + :keyword configuration_api: Information regarding the Configuration API of the API Management + gateway. This is only applicable for API gateway with Standard SKU. + :paramtype configuration_api: ~azure.mgmt.apimanagement.models.GatewayConfigurationApi + :keyword virtual_network_type: The type of VPN in which API Management gateway needs to be + configured in. Known values are: "None", "External", and "Internal". + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + """ + super().__init__(tags=tags, **kwargs) + self.sku = sku + self.etag = None + self.provisioning_state = None + self.target_provisioning_state = None + self.created_at_utc = None + self.frontend = frontend + self.backend = backend + self.configuration_api = configuration_api + self.virtual_network_type = virtual_network_type + + +class ApiManagementGatewayUpdateProperties(ApiManagementGatewayBaseProperties): + """Properties of an API Management gateway resource description. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: The current provisioning state of the API Management gateway which + can be one of the following: + Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + :vartype provisioning_state: str + :ivar target_provisioning_state: The provisioning state of the API Management gateway, which is + targeted by the long running operation started on the gateway. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management gateway.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime + :ivar frontend: Information regarding how the gateway should be exposed. + :vartype frontend: ~azure.mgmt.apimanagement.models.FrontendConfiguration + :ivar backend: Information regarding how the gateway should integrate with backend systems. + :vartype backend: ~azure.mgmt.apimanagement.models.BackendConfiguration + :ivar configuration_api: Information regarding the Configuration API of the API Management + gateway. This is only applicable for API gateway with Standard SKU. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.GatewayConfigurationApi + :ivar virtual_network_type: The type of VPN in which API Management gateway needs to be + configured in. Known values are: "None", "External", and "Internal". + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + """ + + +class ApiManagementServiceApplyNetworkConfigurationParameters(_serialization.Model): # pylint: disable=name-too-long + """Parameter supplied to the Apply Network configuration operation. + + :ivar location: Location of the Api Management service to update for a multi-region service. + For a service deployed in a single region, this parameter is not required. + :vartype location: str + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword location: Location of the Api Management service to update for a multi-region service. + For a service deployed in a single region, this parameter is not required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.location = location + + +class ApiManagementServiceBackupRestoreParameters(_serialization.Model): # pylint: disable=name-too-long + """Parameters supplied to the Backup/Restore of an API Management service operation. + + All required parameters must be populated in order to send to server. + + :ivar storage_account: The name of the Azure storage account (used to place/retrieve the + backup). Required. + :vartype storage_account: str + :ivar container_name: The name of the blob container (used to place/retrieve the backup). + Required. + :vartype container_name: str + :ivar backup_name: The name of the backup file to create/retrieve. Required. + :vartype backup_name: str + :ivar access_type: The type of access to be used for the storage account. Known values are: + "AccessKey", "SystemAssignedManagedIdentity", and "UserAssignedManagedIdentity". + :vartype access_type: str or ~azure.mgmt.apimanagement.models.AccessType + :ivar access_key: Storage account access key. Required only if ``accessType`` is set to + ``AccessKey``. + :vartype access_key: str + :ivar client_id: The Client ID of user assigned managed identity. Required only if + ``accessType`` is set to ``UserAssignedManagedIdentity``. + :vartype client_id: str + """ + + _validation = { + "storage_account": {"required": True}, + "container_name": {"required": True}, + "backup_name": {"required": True}, + } + + _attribute_map = { + "storage_account": {"key": "storageAccount", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "backup_name": {"key": "backupName", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + "access_key": {"key": "accessKey", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__( + self, + *, + storage_account: str, + container_name: str, + backup_name: str, + access_type: Union[str, "_models.AccessType"] = "AccessKey", + access_key: Optional[str] = None, + client_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword storage_account: The name of the Azure storage account (used to place/retrieve the + backup). Required. + :paramtype storage_account: str + :keyword container_name: The name of the blob container (used to place/retrieve the backup). + Required. + :paramtype container_name: str + :keyword backup_name: The name of the backup file to create/retrieve. Required. + :paramtype backup_name: str + :keyword access_type: The type of access to be used for the storage account. Known values are: + "AccessKey", "SystemAssignedManagedIdentity", and "UserAssignedManagedIdentity". + :paramtype access_type: str or ~azure.mgmt.apimanagement.models.AccessType + :keyword access_key: Storage account access key. Required only if ``accessType`` is set to + ``AccessKey``. + :paramtype access_key: str + :keyword client_id: The Client ID of user assigned managed identity. Required only if + ``accessType`` is set to ``UserAssignedManagedIdentity``. + :paramtype client_id: str + """ + super().__init__(**kwargs) + self.storage_account = storage_account + self.container_name = container_name + self.backup_name = backup_name + self.access_type = access_type + self.access_key = access_key + self.client_id = client_id + + +class ApiManagementServiceBaseProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Base Properties of an API Management service resource description. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar notification_sender_email: Email address from which the notification will be sent. + :vartype notification_sender_email: str + :ivar provisioning_state: The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. :vartype provisioning_state: str @@ -2005,6 +2731,8 @@ class ApiManagementServiceBaseProperties(_serialization.Model): # pylint: disab 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar configuration_api: Configuration API configuration of the API Management service. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: @@ -2034,7 +2762,7 @@ class ApiManagementServiceBaseProperties(_serialization.Model): # pylint: disab TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -2072,8 +2800,14 @@ class ApiManagementServiceBaseProperties(_serialization.Model): # pylint: disab :vartype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :ivar platform_version: Compute Platform Version running the service in this location. Known - values are: "undetermined", "stv1", "stv2", and "mtv1". + values are: "undetermined", "stv1", "stv2", "mtv1", and "stv2.1". :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar legacy_portal_status: Status of legacy portal in the API Management service. Known values + are: "Enabled" and "Disabled". + :vartype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :ivar developer_portal_status: Status of developer portal in this API Management service. Known + values are: "Enabled" and "Disabled". + :vartype developer_portal_status: str or ~azure.mgmt.apimanagement.models.DeveloperPortalStatus """ _validation = { @@ -2109,6 +2843,7 @@ class ApiManagementServiceBaseProperties(_serialization.Model): # pylint: disab "private_ip_addresses": {"key": "privateIPAddresses", "type": "[str]"}, "public_ip_address_id": {"key": "publicIpAddressId", "type": "str"}, "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "configuration_api": {"key": "configurationApi", "type": "ConfigurationApi"}, "virtual_network_configuration": {"key": "virtualNetworkConfiguration", "type": "VirtualNetworkConfiguration"}, "additional_locations": {"key": "additionalLocations", "type": "[AdditionalLocation]"}, "custom_properties": {"key": "customProperties", "type": "{str}"}, @@ -2125,6 +2860,8 @@ class ApiManagementServiceBaseProperties(_serialization.Model): # pylint: disab "type": "[RemotePrivateEndpointConnectionWrapper]", }, "platform_version": {"key": "platformVersion", "type": "str"}, + "legacy_portal_status": {"key": "legacyPortalStatus", "type": "str"}, + "developer_portal_status": {"key": "developerPortalStatus", "type": "str"}, } def __init__( # pylint: disable=too-many-locals @@ -2134,6 +2871,7 @@ def __init__( # pylint: disable=too-many-locals hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + configuration_api: Optional["_models.ConfigurationApi"] = None, virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, @@ -2141,10 +2879,12 @@ def __init__( # pylint: disable=too-many-locals enable_client_certificate: bool = False, nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, disable_gateway: bool = False, - virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: bool = False, private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, + legacy_portal_status: Union[str, "_models.LegacyPortalStatus"] = "Enabled", + developer_portal_status: Union[str, "_models.DeveloperPortalStatus"] = "Enabled", **kwargs: Any ) -> None: """ @@ -2162,6 +2902,8 @@ def __init__( # pylint: disable=too-many-locals 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :keyword configuration_api: Configuration API configuration of the API Management service. + :paramtype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: @@ -2191,7 +2933,7 @@ def __init__( # pylint: disable=too-many-locals TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -2225,6 +2967,13 @@ def __init__( # pylint: disable=too-many-locals :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword legacy_portal_status: Status of legacy portal in the API Management service. Known + values are: "Enabled" and "Disabled". + :paramtype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :keyword developer_portal_status: Status of developer portal in this API Management service. + Known values are: "Enabled" and "Disabled". + :paramtype developer_portal_status: str or + ~azure.mgmt.apimanagement.models.DeveloperPortalStatus """ super().__init__(**kwargs) self.notification_sender_email = notification_sender_email @@ -2242,6 +2991,7 @@ def __init__( # pylint: disable=too-many-locals self.private_ip_addresses = None self.public_ip_address_id = public_ip_address_id self.public_network_access = public_network_access + self.configuration_api = configuration_api self.virtual_network_configuration = virtual_network_configuration self.additional_locations = additional_locations self.custom_properties = custom_properties @@ -2255,6 +3005,8 @@ def __init__( # pylint: disable=too-many-locals self.restore = restore self.private_endpoint_connections = private_endpoint_connections self.platform_version = None + self.legacy_portal_status = legacy_portal_status + self.developer_portal_status = developer_portal_status class ApiManagementServiceCheckNameAvailabilityParameters(_serialization.Model): # pylint: disable=name-too-long @@ -2524,6 +3276,8 @@ class ApiManagementServiceProperties( 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar configuration_api: Configuration API configuration of the API Management service. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: @@ -2553,7 +3307,7 @@ class ApiManagementServiceProperties( TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -2591,8 +3345,14 @@ class ApiManagementServiceProperties( :vartype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :ivar platform_version: Compute Platform Version running the service in this location. Known - values are: "undetermined", "stv1", "stv2", and "mtv1". + values are: "undetermined", "stv1", "stv2", "mtv1", and "stv2.1". :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar legacy_portal_status: Status of legacy portal in the API Management service. Known values + are: "Enabled" and "Disabled". + :vartype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :ivar developer_portal_status: Status of developer portal in this API Management service. Known + values are: "Enabled" and "Disabled". + :vartype developer_portal_status: str or ~azure.mgmt.apimanagement.models.DeveloperPortalStatus :ivar publisher_email: Publisher email. Required. :vartype publisher_email: str :ivar publisher_name: Publisher name. Required. @@ -2634,6 +3394,7 @@ class ApiManagementServiceProperties( "private_ip_addresses": {"key": "privateIPAddresses", "type": "[str]"}, "public_ip_address_id": {"key": "publicIpAddressId", "type": "str"}, "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "configuration_api": {"key": "configurationApi", "type": "ConfigurationApi"}, "virtual_network_configuration": {"key": "virtualNetworkConfiguration", "type": "VirtualNetworkConfiguration"}, "additional_locations": {"key": "additionalLocations", "type": "[AdditionalLocation]"}, "custom_properties": {"key": "customProperties", "type": "{str}"}, @@ -2650,6 +3411,8 @@ class ApiManagementServiceProperties( "type": "[RemotePrivateEndpointConnectionWrapper]", }, "platform_version": {"key": "platformVersion", "type": "str"}, + "legacy_portal_status": {"key": "legacyPortalStatus", "type": "str"}, + "developer_portal_status": {"key": "developerPortalStatus", "type": "str"}, "publisher_email": {"key": "publisherEmail", "type": "str"}, "publisher_name": {"key": "publisherName", "type": "str"}, } @@ -2663,6 +3426,7 @@ def __init__( # pylint: disable=too-many-locals hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + configuration_api: Optional["_models.ConfigurationApi"] = None, virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, @@ -2670,10 +3434,12 @@ def __init__( # pylint: disable=too-many-locals enable_client_certificate: bool = False, nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, disable_gateway: bool = False, - virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: bool = False, private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, + legacy_portal_status: Union[str, "_models.LegacyPortalStatus"] = "Enabled", + developer_portal_status: Union[str, "_models.DeveloperPortalStatus"] = "Enabled", **kwargs: Any ) -> None: """ @@ -2691,6 +3457,8 @@ def __init__( # pylint: disable=too-many-locals 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :keyword configuration_api: Configuration API configuration of the API Management service. + :paramtype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: @@ -2720,7 +3488,7 @@ def __init__( # pylint: disable=too-many-locals TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -2754,6 +3522,13 @@ def __init__( # pylint: disable=too-many-locals :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword legacy_portal_status: Status of legacy portal in the API Management service. Known + values are: "Enabled" and "Disabled". + :paramtype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :keyword developer_portal_status: Status of developer portal in this API Management service. + Known values are: "Enabled" and "Disabled". + :paramtype developer_portal_status: str or + ~azure.mgmt.apimanagement.models.DeveloperPortalStatus :keyword publisher_email: Publisher email. Required. :paramtype publisher_email: str :keyword publisher_name: Publisher name. Required. @@ -2764,6 +3539,7 @@ def __init__( # pylint: disable=too-many-locals hostname_configurations=hostname_configurations, public_ip_address_id=public_ip_address_id, public_network_access=public_network_access, + configuration_api=configuration_api, virtual_network_configuration=virtual_network_configuration, additional_locations=additional_locations, custom_properties=custom_properties, @@ -2775,52 +3551,14 @@ def __init__( # pylint: disable=too-many-locals api_version_constraint=api_version_constraint, restore=restore, private_endpoint_connections=private_endpoint_connections, + legacy_portal_status=legacy_portal_status, + developer_portal_status=developer_portal_status, **kwargs ) self.publisher_email = publisher_email self.publisher_name = publisher_name -class ApimResource(_serialization.Model): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.tags = tags - - class ApiManagementServiceResource(ApimResource): # pylint: disable=too-many-instance-attributes """A single API Management service resource in List or Get response. @@ -2890,6 +3628,8 @@ class ApiManagementServiceResource(ApimResource): # pylint: disable=too-many-in 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar configuration_api: Configuration API configuration of the API Management service. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: @@ -2919,7 +3659,7 @@ class ApiManagementServiceResource(ApimResource): # pylint: disable=too-many-in TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -2957,8 +3697,14 @@ class ApiManagementServiceResource(ApimResource): # pylint: disable=too-many-in :vartype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :ivar platform_version: Compute Platform Version running the service in this location. Known - values are: "undetermined", "stv1", "stv2", and "mtv1". + values are: "undetermined", "stv1", "stv2", "mtv1", and "stv2.1". :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar legacy_portal_status: Status of legacy portal in the API Management service. Known values + are: "Enabled" and "Disabled". + :vartype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :ivar developer_portal_status: Status of developer portal in this API Management service. Known + values are: "Enabled" and "Disabled". + :vartype developer_portal_status: str or ~azure.mgmt.apimanagement.models.DeveloperPortalStatus :ivar publisher_email: Publisher email. Required. :vartype publisher_email: str :ivar publisher_name: Publisher name. Required. @@ -3017,6 +3763,7 @@ class ApiManagementServiceResource(ApimResource): # pylint: disable=too-many-in "private_ip_addresses": {"key": "properties.privateIPAddresses", "type": "[str]"}, "public_ip_address_id": {"key": "properties.publicIpAddressId", "type": "str"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "configuration_api": {"key": "properties.configurationApi", "type": "ConfigurationApi"}, "virtual_network_configuration": { "key": "properties.virtualNetworkConfiguration", "type": "VirtualNetworkConfiguration", @@ -3036,6 +3783,8 @@ class ApiManagementServiceResource(ApimResource): # pylint: disable=too-many-in "type": "[RemotePrivateEndpointConnectionWrapper]", }, "platform_version": {"key": "properties.platformVersion", "type": "str"}, + "legacy_portal_status": {"key": "properties.legacyPortalStatus", "type": "str"}, + "developer_portal_status": {"key": "properties.developerPortalStatus", "type": "str"}, "publisher_email": {"key": "properties.publisherEmail", "type": "str"}, "publisher_name": {"key": "properties.publisherName", "type": "str"}, } @@ -3054,6 +3803,7 @@ def __init__( # pylint: disable=too-many-locals hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + configuration_api: Optional["_models.ConfigurationApi"] = None, virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, @@ -3061,10 +3811,12 @@ def __init__( # pylint: disable=too-many-locals enable_client_certificate: bool = False, nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, disable_gateway: bool = False, - virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: bool = False, private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, + legacy_portal_status: Union[str, "_models.LegacyPortalStatus"] = "Enabled", + developer_portal_status: Union[str, "_models.DeveloperPortalStatus"] = "Enabled", **kwargs: Any ) -> None: """ @@ -3092,6 +3844,8 @@ def __init__( # pylint: disable=too-many-locals 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :keyword configuration_api: Configuration API configuration of the API Management service. + :paramtype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: @@ -3121,7 +3875,7 @@ def __init__( # pylint: disable=too-many-locals TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -3155,6 +3909,13 @@ def __init__( # pylint: disable=too-many-locals :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword legacy_portal_status: Status of legacy portal in the API Management service. Known + values are: "Enabled" and "Disabled". + :paramtype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :keyword developer_portal_status: Status of developer portal in this API Management service. + Known values are: "Enabled" and "Disabled". + :paramtype developer_portal_status: str or + ~azure.mgmt.apimanagement.models.DeveloperPortalStatus :keyword publisher_email: Publisher email. Required. :paramtype publisher_email: str :keyword publisher_name: Publisher name. Required. @@ -3182,6 +3943,7 @@ def __init__( # pylint: disable=too-many-locals self.private_ip_addresses = None self.public_ip_address_id = public_ip_address_id self.public_network_access = public_network_access + self.configuration_api = configuration_api self.virtual_network_configuration = virtual_network_configuration self.additional_locations = additional_locations self.custom_properties = custom_properties @@ -3195,6 +3957,8 @@ def __init__( # pylint: disable=too-many-locals self.restore = restore self.private_endpoint_connections = private_endpoint_connections self.platform_version = None + self.legacy_portal_status = legacy_portal_status + self.developer_portal_status = developer_portal_status self.publisher_email = publisher_email self.publisher_name = publisher_name @@ -3204,8 +3968,8 @@ class ApiManagementServiceSkuProperties(_serialization.Model): All required parameters must be populated in order to send to server. - :ivar name: Name of the Sku. Required. Known values are: "Developer", "Standard", "Premium", - "Basic", "Consumption", and "Isolated". + :ivar name: Name of the Sku. Required. Known values are: "Standard", + "WorkspaceGatewayStandard", and "WorkspaceGatewayPremium". :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType :ivar capacity: Capacity of the SKU (number of deployed units of the SKU). For Consumption SKU capacity must be specified as 0. Required. @@ -3224,8 +3988,8 @@ class ApiManagementServiceSkuProperties(_serialization.Model): def __init__(self, *, name: Union[str, "_models.SkuType"], capacity: int, **kwargs: Any) -> None: """ - :keyword name: Name of the Sku. Required. Known values are: "Developer", "Standard", "Premium", - "Basic", "Consumption", and "Isolated". + :keyword name: Name of the Sku. Required. Known values are: "Standard", + "WorkspaceGatewayStandard", and "WorkspaceGatewayPremium". :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType :keyword capacity: Capacity of the SKU (number of deployed units of the SKU). For Consumption SKU capacity must be specified as 0. Required. @@ -3299,6 +4063,8 @@ class ApiManagementServiceUpdateParameters(ApimResource): # pylint: disable=too 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar configuration_api: Configuration API configuration of the API Management service. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: @@ -3328,7 +4094,7 @@ class ApiManagementServiceUpdateParameters(ApimResource): # pylint: disable=too TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -3366,8 +4132,14 @@ class ApiManagementServiceUpdateParameters(ApimResource): # pylint: disable=too :vartype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :ivar platform_version: Compute Platform Version running the service in this location. Known - values are: "undetermined", "stv1", "stv2", and "mtv1". + values are: "undetermined", "stv1", "stv2", "mtv1", and "stv2.1". :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar legacy_portal_status: Status of legacy portal in the API Management service. Known values + are: "Enabled" and "Disabled". + :vartype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :ivar developer_portal_status: Status of developer portal in this API Management service. Known + values are: "Enabled" and "Disabled". + :vartype developer_portal_status: str or ~azure.mgmt.apimanagement.models.DeveloperPortalStatus :ivar publisher_email: Publisher email. :vartype publisher_email: str :ivar publisher_name: Publisher name. @@ -3421,6 +4193,7 @@ class ApiManagementServiceUpdateParameters(ApimResource): # pylint: disable=too "private_ip_addresses": {"key": "properties.privateIPAddresses", "type": "[str]"}, "public_ip_address_id": {"key": "properties.publicIpAddressId", "type": "str"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "configuration_api": {"key": "properties.configurationApi", "type": "ConfigurationApi"}, "virtual_network_configuration": { "key": "properties.virtualNetworkConfiguration", "type": "VirtualNetworkConfiguration", @@ -3440,6 +4213,8 @@ class ApiManagementServiceUpdateParameters(ApimResource): # pylint: disable=too "type": "[RemotePrivateEndpointConnectionWrapper]", }, "platform_version": {"key": "properties.platformVersion", "type": "str"}, + "legacy_portal_status": {"key": "properties.legacyPortalStatus", "type": "str"}, + "developer_portal_status": {"key": "properties.developerPortalStatus", "type": "str"}, "publisher_email": {"key": "properties.publisherEmail", "type": "str"}, "publisher_name": {"key": "properties.publisherName", "type": "str"}, } @@ -3455,6 +4230,7 @@ def __init__( # pylint: disable=too-many-locals hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + configuration_api: Optional["_models.ConfigurationApi"] = None, virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, @@ -3462,10 +4238,12 @@ def __init__( # pylint: disable=too-many-locals enable_client_certificate: bool = False, nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, disable_gateway: bool = False, - virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: bool = False, private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, + legacy_portal_status: Union[str, "_models.LegacyPortalStatus"] = "Enabled", + developer_portal_status: Union[str, "_models.DeveloperPortalStatus"] = "Enabled", publisher_email: Optional[str] = None, publisher_name: Optional[str] = None, **kwargs: Any @@ -3493,6 +4271,8 @@ def __init__( # pylint: disable=too-many-locals 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :keyword configuration_api: Configuration API configuration of the API Management service. + :paramtype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: @@ -3522,7 +4302,7 @@ def __init__( # pylint: disable=too-many-locals TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -3556,6 +4336,13 @@ def __init__( # pylint: disable=too-many-locals :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword legacy_portal_status: Status of legacy portal in the API Management service. Known + values are: "Enabled" and "Disabled". + :paramtype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :keyword developer_portal_status: Status of developer portal in this API Management service. + Known values are: "Enabled" and "Disabled". + :paramtype developer_portal_status: str or + ~azure.mgmt.apimanagement.models.DeveloperPortalStatus :keyword publisher_email: Publisher email. :paramtype publisher_email: str :keyword publisher_name: Publisher name. @@ -3581,6 +4368,7 @@ def __init__( # pylint: disable=too-many-locals self.private_ip_addresses = None self.public_ip_address_id = public_ip_address_id self.public_network_access = public_network_access + self.configuration_api = configuration_api self.virtual_network_configuration = virtual_network_configuration self.additional_locations = additional_locations self.custom_properties = custom_properties @@ -3594,6 +4382,8 @@ def __init__( # pylint: disable=too-many-locals self.restore = restore self.private_endpoint_connections = private_endpoint_connections self.platform_version = None + self.legacy_portal_status = legacy_portal_status + self.developer_portal_status = developer_portal_status self.publisher_email = publisher_email self.publisher_name = publisher_name @@ -3647,6 +4437,8 @@ class ApiManagementServiceUpdateProperties( 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar configuration_api: Configuration API configuration of the API Management service. + :vartype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: @@ -3676,7 +4468,7 @@ class ApiManagementServiceUpdateProperties( TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -3714,8 +4506,14 @@ class ApiManagementServiceUpdateProperties( :vartype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :ivar platform_version: Compute Platform Version running the service in this location. Known - values are: "undetermined", "stv1", "stv2", and "mtv1". + values are: "undetermined", "stv1", "stv2", "mtv1", and "stv2.1". :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar legacy_portal_status: Status of legacy portal in the API Management service. Known values + are: "Enabled" and "Disabled". + :vartype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :ivar developer_portal_status: Status of developer portal in this API Management service. Known + values are: "Enabled" and "Disabled". + :vartype developer_portal_status: str or ~azure.mgmt.apimanagement.models.DeveloperPortalStatus :ivar publisher_email: Publisher email. :vartype publisher_email: str :ivar publisher_name: Publisher name. @@ -3757,6 +4555,7 @@ class ApiManagementServiceUpdateProperties( "private_ip_addresses": {"key": "privateIPAddresses", "type": "[str]"}, "public_ip_address_id": {"key": "publicIpAddressId", "type": "str"}, "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "configuration_api": {"key": "configurationApi", "type": "ConfigurationApi"}, "virtual_network_configuration": {"key": "virtualNetworkConfiguration", "type": "VirtualNetworkConfiguration"}, "additional_locations": {"key": "additionalLocations", "type": "[AdditionalLocation]"}, "custom_properties": {"key": "customProperties", "type": "{str}"}, @@ -3773,6 +4572,8 @@ class ApiManagementServiceUpdateProperties( "type": "[RemotePrivateEndpointConnectionWrapper]", }, "platform_version": {"key": "platformVersion", "type": "str"}, + "legacy_portal_status": {"key": "legacyPortalStatus", "type": "str"}, + "developer_portal_status": {"key": "developerPortalStatus", "type": "str"}, "publisher_email": {"key": "publisherEmail", "type": "str"}, "publisher_name": {"key": "publisherName", "type": "str"}, } @@ -3784,6 +4585,7 @@ def __init__( # pylint: disable=too-many-locals hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + configuration_api: Optional["_models.ConfigurationApi"] = None, virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, @@ -3791,10 +4593,12 @@ def __init__( # pylint: disable=too-many-locals enable_client_certificate: bool = False, nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, disable_gateway: bool = False, - virtual_network_type: Union[str, "_models.VirtualNetworkType"] = "None", + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: bool = False, private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, + legacy_portal_status: Union[str, "_models.LegacyPortalStatus"] = "Enabled", + developer_portal_status: Union[str, "_models.DeveloperPortalStatus"] = "Enabled", publisher_email: Optional[str] = None, publisher_name: Optional[str] = None, **kwargs: Any @@ -3814,6 +4618,8 @@ def __init__( # pylint: disable=too-many-locals 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :keyword configuration_api: Configuration API configuration of the API Management service. + :paramtype configuration_api: ~azure.mgmt.apimanagement.models.ConfigurationApi :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: @@ -3843,7 +4649,7 @@ def __init__( # pylint: disable=too-many-locals TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\\ ``false``. The default value is ``true`` for them.
Note: The following ciphers can't be disabled since they are required by internal platform components: TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256. # pylint: disable=line-too-long @@ -3877,6 +4683,13 @@ def __init__( # pylint: disable=too-many-locals :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword legacy_portal_status: Status of legacy portal in the API Management service. Known + values are: "Enabled" and "Disabled". + :paramtype legacy_portal_status: str or ~azure.mgmt.apimanagement.models.LegacyPortalStatus + :keyword developer_portal_status: Status of developer portal in this API Management service. + Known values are: "Enabled" and "Disabled". + :paramtype developer_portal_status: str or + ~azure.mgmt.apimanagement.models.DeveloperPortalStatus :keyword publisher_email: Publisher email. :paramtype publisher_email: str :keyword publisher_name: Publisher name. @@ -3887,6 +4700,7 @@ def __init__( # pylint: disable=too-many-locals hostname_configurations=hostname_configurations, public_ip_address_id=public_ip_address_id, public_network_access=public_network_access, + configuration_api=configuration_api, virtual_network_configuration=virtual_network_configuration, additional_locations=additional_locations, custom_properties=custom_properties, @@ -3898,6 +4712,8 @@ def __init__( # pylint: disable=too-many-locals api_version_constraint=api_version_constraint, restore=restore, private_endpoint_connections=private_endpoint_connections, + legacy_portal_status=legacy_portal_status, + developer_portal_status=developer_portal_status, **kwargs ) self.publisher_email = publisher_email @@ -3914,7 +4730,7 @@ class ApiManagementSku(_serialization.Model): # pylint: disable=too-many-instan :ivar name: The name of SKU. :vartype name: str :ivar tier: Specifies the tier of virtual machines in a scale set.:code:`
`:code:`
` - Possible Values::code:`
`:code:`
` **Standard**\ :code:`
`:code:`
` + Possible Values::code:`
`:code:`
` **Standard**\\ :code:`
`:code:`
` **Basic**. :vartype tier: str :ivar size: The Size of the SKU. @@ -4256,6 +5072,144 @@ def __init__(self, **kwargs: Any) -> None: self.capabilities = None +class ApiManagementWorkspaceLinksListResult(_serialization.Model): + """The response of the List API Management WorkspaceLink operation. + + All required parameters must be populated in order to send to server. + + :ivar value: Result of the List API Management WorkspaceLinks operation. Required. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list + of API Management services. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApiManagementWorkspaceLinksResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: List["_models.ApiManagementWorkspaceLinksResource"], + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Result of the List API Management WorkspaceLinks operation. Required. + :paramtype value: list[~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of API Management services. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class WorkspaceLinksBaseProperties(_serialization.Model): + """WorkspaceLinksBaseProperties. + + :ivar workspace_id: The link to the API Management service workspace. + :vartype workspace_id: str + :ivar gateways: The array of linked gateways. + :vartype gateways: list[~azure.mgmt.apimanagement.models.WorkspaceLinksGateway] + """ + + _attribute_map = { + "workspace_id": {"key": "workspaceId", "type": "str"}, + "gateways": {"key": "gateways", "type": "[WorkspaceLinksGateway]"}, + } + + def __init__( + self, + *, + workspace_id: Optional[str] = None, + gateways: Optional[List["_models.WorkspaceLinksGateway"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword workspace_id: The link to the API Management service workspace. + :paramtype workspace_id: str + :keyword gateways: The array of linked gateways. + :paramtype gateways: list[~azure.mgmt.apimanagement.models.WorkspaceLinksGateway] + """ + super().__init__(**kwargs) + self.workspace_id = workspace_id + self.gateways = gateways + + +class ApiManagementWorkspaceLinksProperties(WorkspaceLinksBaseProperties): + """Properties of an API Management workspaceLinks resource. + + :ivar workspace_id: The link to the API Management service workspace. + :vartype workspace_id: str + :ivar gateways: The array of linked gateways. + :vartype gateways: list[~azure.mgmt.apimanagement.models.WorkspaceLinksGateway] + """ + + +class ApiManagementWorkspaceLinksResource(ProxyResource): + """A single API Management WorkspaceLinks in List or Get response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: ETag of the resource. + :vartype etag: str + :ivar workspace_id: The link to the API Management service workspace. + :vartype workspace_id: str + :ivar gateways: The array of linked gateways. + :vartype gateways: list[~azure.mgmt.apimanagement.models.WorkspaceLinksGateway] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + "gateways": {"key": "properties.gateways", "type": "[WorkspaceLinksGateway]"}, + } + + def __init__( + self, + *, + workspace_id: Optional[str] = None, + gateways: Optional[List["_models.WorkspaceLinksGateway"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword workspace_id: The link to the API Management service workspace. + :paramtype workspace_id: str + :keyword gateways: The array of linked gateways. + :paramtype gateways: list[~azure.mgmt.apimanagement.models.WorkspaceLinksGateway] + """ + super().__init__(**kwargs) + self.etag = None + self.workspace_id = workspace_id + self.gateways = gateways + + class ApiReleaseCollection(_serialization.Model): """Paged ApiRelease list representation. @@ -4506,7 +5460,8 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): # pylint: disabl :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", "odata", + and "grpc". :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -4617,7 +5572,8 @@ def __init__( :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", + "odata", and "grpc". :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -4692,7 +5648,8 @@ class ApiUpdateContract(_serialization.Model): # pylint: disable=too-many-insta :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", "odata", + and "grpc". :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -4802,7 +5759,8 @@ def __init__( :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", and "graphql". + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql", + "odata", and "grpc". :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. @@ -5355,8 +6313,9 @@ class AssociationContract(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar provisioning_state: Provisioning state. Default value is "created". - :vartype provisioning_state: str + :ivar provisioning_state: Provisioning state. Known values are: "Activating", "Canceled", + "Failed", "Succeeded", "Terminating", "Upgrading", "Updating", and "created". + :vartype provisioning_state: str or ~azure.mgmt.apimanagement.models.ProvisioningState """ _validation = { @@ -5372,10 +6331,13 @@ class AssociationContract(ProxyResource): "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__(self, *, provisioning_state: Optional[Literal["created"]] = None, **kwargs: Any) -> None: + def __init__( + self, *, provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, **kwargs: Any + ) -> None: """ - :keyword provisioning_state: Provisioning state. Default value is "created". - :paramtype provisioning_state: str + :keyword provisioning_state: Provisioning state. Known values are: "Activating", "Canceled", + "Failed", "Succeeded", "Terminating", "Upgrading", "Updating", and "created". + :paramtype provisioning_state: str or ~azure.mgmt.apimanagement.models.ProvisioningState """ super().__init__(**kwargs) self.provisioning_state = provisioning_state @@ -5493,6 +6455,8 @@ class AuthorizationAccessPolicyContract(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str + :ivar app_ids: The allowed Azure Active Directory Application IDs. + :vartype app_ids: list[str] :ivar tenant_id: The Tenant Id. :vartype tenant_id: str :ivar object_id: The Object Id. @@ -5509,18 +6473,29 @@ class AuthorizationAccessPolicyContract(ProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "app_ids": {"key": "properties.appIds", "type": "[str]"}, "tenant_id": {"key": "properties.tenantId", "type": "str"}, "object_id": {"key": "properties.objectId", "type": "str"}, } - def __init__(self, *, tenant_id: Optional[str] = None, object_id: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + app_ids: Optional[List[str]] = None, + tenant_id: Optional[str] = None, + object_id: Optional[str] = None, + **kwargs: Any + ) -> None: """ + :keyword app_ids: The allowed Azure Active Directory Application IDs. + :paramtype app_ids: list[str] :keyword tenant_id: The Tenant Id. :paramtype tenant_id: str :keyword object_id: The Object Id. :paramtype object_id: str """ super().__init__(**kwargs) + self.app_ids = app_ids self.tenant_id = tenant_id self.object_id = object_id @@ -6984,6 +7959,13 @@ class BackendBaseParameters(_serialization.Model): :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :ivar circuit_breaker: Backend Circuit Breaker Configuration. + :vartype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :ivar pool: + :vartype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :ivar type: Type of the backend. A backend can be either Single or Pool. Known values are: + "Single" and "Pool". + :vartype type: str or ~azure.mgmt.apimanagement.models.BackendType """ _validation = { @@ -7000,6 +7982,9 @@ class BackendBaseParameters(_serialization.Model): "credentials": {"key": "credentials", "type": "BackendCredentialsContract"}, "proxy": {"key": "proxy", "type": "BackendProxyContract"}, "tls": {"key": "tls", "type": "BackendTlsProperties"}, + "circuit_breaker": {"key": "circuitBreaker", "type": "BackendCircuitBreaker"}, + "pool": {"key": "pool", "type": "BackendBaseParametersPool"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -7012,6 +7997,9 @@ def __init__( credentials: Optional["_models.BackendCredentialsContract"] = None, proxy: Optional["_models.BackendProxyContract"] = None, tls: Optional["_models.BackendTlsProperties"] = None, + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = None, + pool: Optional["_models.BackendBaseParametersPool"] = None, + type: Optional[Union[str, "_models.BackendType"]] = None, **kwargs: Any ) -> None: """ @@ -7030,6 +8018,13 @@ def __init__( :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :keyword circuit_breaker: Backend Circuit Breaker Configuration. + :paramtype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :keyword pool: + :paramtype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :keyword type: Type of the backend. A backend can be either Single or Pool. Known values are: + "Single" and "Pool". + :paramtype type: str or ~azure.mgmt.apimanagement.models.BackendType """ super().__init__(**kwargs) self.title = title @@ -7039,6 +8034,65 @@ def __init__( self.credentials = credentials self.proxy = proxy self.tls = tls + self.circuit_breaker = circuit_breaker + self.pool = pool + self.type = type + + +class BackendPool(_serialization.Model): + """Backend pool information. + + :ivar services: The list of backend entities belonging to a pool. + :vartype services: list[~azure.mgmt.apimanagement.models.BackendPoolItem] + """ + + _validation = { + "services": {"min_items": 1}, + } + + _attribute_map = { + "services": {"key": "services", "type": "[BackendPoolItem]"}, + } + + def __init__(self, *, services: Optional[List["_models.BackendPoolItem"]] = None, **kwargs: Any) -> None: + """ + :keyword services: The list of backend entities belonging to a pool. + :paramtype services: list[~azure.mgmt.apimanagement.models.BackendPoolItem] + """ + super().__init__(**kwargs) + self.services = services + + +class BackendBaseParametersPool(BackendPool): + """BackendBaseParametersPool. + + :ivar services: The list of backend entities belonging to a pool. + :vartype services: list[~azure.mgmt.apimanagement.models.BackendPoolItem] + """ + + +class BackendCircuitBreaker(_serialization.Model): + """The configuration of the backend circuit breaker. + + :ivar rules: The rules for tripping the backend. + :vartype rules: list[~azure.mgmt.apimanagement.models.CircuitBreakerRule] + """ + + _validation = { + "rules": {"max_items": 15, "min_items": 0}, + } + + _attribute_map = { + "rules": {"key": "rules", "type": "[CircuitBreakerRule]"}, + } + + def __init__(self, *, rules: Optional[List["_models.CircuitBreakerRule"]] = None, **kwargs: Any) -> None: + """ + :keyword rules: The rules for tripping the backend. + :paramtype rules: list[~azure.mgmt.apimanagement.models.CircuitBreakerRule] + """ + super().__init__(**kwargs) + self.rules = rules class BackendCollection(_serialization.Model): @@ -7080,6 +8134,26 @@ def __init__( self.next_link = next_link +class BackendConfiguration(_serialization.Model): + """Information regarding how the gateway should integrate with backend systems. + + :ivar subnet: The default hostname of the data-plane gateway to which requests can be sent. + :vartype subnet: ~azure.mgmt.apimanagement.models.BackendSubnetConfiguration + """ + + _attribute_map = { + "subnet": {"key": "subnet", "type": "BackendSubnetConfiguration"}, + } + + def __init__(self, *, subnet: Optional["_models.BackendSubnetConfiguration"] = None, **kwargs: Any) -> None: + """ + :keyword subnet: The default hostname of the data-plane gateway to which requests can be sent. + :paramtype subnet: ~azure.mgmt.apimanagement.models.BackendSubnetConfiguration + """ + super().__init__(**kwargs) + self.subnet = subnet + + class BackendContract(ProxyResource): # pylint: disable=too-many-instance-attributes """Backend details. @@ -7108,6 +8182,13 @@ class BackendContract(ProxyResource): # pylint: disable=too-many-instance-attri :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :ivar circuit_breaker: Backend Circuit Breaker Configuration. + :vartype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :ivar pool: + :vartype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :ivar type_properties_type: Type of the backend. A backend can be either Single or Pool. Known + values are: "Single" and "Pool". + :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.BackendType :ivar url: Runtime Url of the Backend. :vartype url: str :ivar protocol: Backend communication protocol. Known values are: "http" and "soap". @@ -7135,6 +8216,9 @@ class BackendContract(ProxyResource): # pylint: disable=too-many-instance-attri "credentials": {"key": "properties.credentials", "type": "BackendCredentialsContract"}, "proxy": {"key": "properties.proxy", "type": "BackendProxyContract"}, "tls": {"key": "properties.tls", "type": "BackendTlsProperties"}, + "circuit_breaker": {"key": "properties.circuitBreaker", "type": "BackendCircuitBreaker"}, + "pool": {"key": "properties.pool", "type": "BackendBaseParametersPool"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, "url": {"key": "properties.url", "type": "str"}, "protocol": {"key": "properties.protocol", "type": "str"}, } @@ -7149,6 +8233,9 @@ def __init__( credentials: Optional["_models.BackendCredentialsContract"] = None, proxy: Optional["_models.BackendProxyContract"] = None, tls: Optional["_models.BackendTlsProperties"] = None, + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = None, + pool: Optional["_models.BackendBaseParametersPool"] = None, + type_properties_type: Optional[Union[str, "_models.BackendType"]] = None, url: Optional[str] = None, protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs: Any @@ -7169,6 +8256,13 @@ def __init__( :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :keyword circuit_breaker: Backend Circuit Breaker Configuration. + :paramtype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :keyword pool: + :paramtype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :keyword type_properties_type: Type of the backend. A backend can be either Single or Pool. + Known values are: "Single" and "Pool". + :paramtype type_properties_type: str or ~azure.mgmt.apimanagement.models.BackendType :keyword url: Runtime Url of the Backend. :paramtype url: str :keyword protocol: Backend communication protocol. Known values are: "http" and "soap". @@ -7182,11 +8276,14 @@ def __init__( self.credentials = credentials self.proxy = proxy self.tls = tls + self.circuit_breaker = circuit_breaker + self.pool = pool + self.type_properties_type = type_properties_type self.url = url self.protocol = protocol -class BackendContractProperties(BackendBaseParameters): +class BackendContractProperties(BackendBaseParameters): # pylint: disable=too-many-instance-attributes """Parameters supplied to the Create Backend operation. All required parameters must be populated in order to send to server. @@ -7206,6 +8303,13 @@ class BackendContractProperties(BackendBaseParameters): :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :ivar circuit_breaker: Backend Circuit Breaker Configuration. + :vartype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :ivar pool: + :vartype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :ivar type: Type of the backend. A backend can be either Single or Pool. Known values are: + "Single" and "Pool". + :vartype type: str or ~azure.mgmt.apimanagement.models.BackendType :ivar url: Runtime Url of the Backend. Required. :vartype url: str :ivar protocol: Backend communication protocol. Required. Known values are: "http" and "soap". @@ -7228,6 +8332,9 @@ class BackendContractProperties(BackendBaseParameters): "credentials": {"key": "credentials", "type": "BackendCredentialsContract"}, "proxy": {"key": "proxy", "type": "BackendProxyContract"}, "tls": {"key": "tls", "type": "BackendTlsProperties"}, + "circuit_breaker": {"key": "circuitBreaker", "type": "BackendCircuitBreaker"}, + "pool": {"key": "pool", "type": "BackendBaseParametersPool"}, + "type": {"key": "type", "type": "str"}, "url": {"key": "url", "type": "str"}, "protocol": {"key": "protocol", "type": "str"}, } @@ -7244,6 +8351,9 @@ def __init__( credentials: Optional["_models.BackendCredentialsContract"] = None, proxy: Optional["_models.BackendProxyContract"] = None, tls: Optional["_models.BackendTlsProperties"] = None, + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = None, + pool: Optional["_models.BackendBaseParametersPool"] = None, + type: Optional[Union[str, "_models.BackendType"]] = None, **kwargs: Any ) -> None: """ @@ -7262,6 +8372,13 @@ def __init__( :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :keyword circuit_breaker: Backend Circuit Breaker Configuration. + :paramtype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :keyword pool: + :paramtype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :keyword type: Type of the backend. A backend can be either Single or Pool. Known values are: + "Single" and "Pool". + :paramtype type: str or ~azure.mgmt.apimanagement.models.BackendType :keyword url: Runtime Url of the Backend. Required. :paramtype url: str :keyword protocol: Backend communication protocol. Required. Known values are: "http" and @@ -7276,6 +8393,9 @@ def __init__( credentials=credentials, proxy=proxy, tls=tls, + circuit_breaker=circuit_breaker, + pool=pool, + type=type, **kwargs ) self.url = url @@ -7336,11 +8456,64 @@ def __init__( ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials """ super().__init__(**kwargs) - self.certificate_ids = certificate_ids - self.certificate = certificate - self.query = query - self.header = header - self.authorization = authorization + self.certificate_ids = certificate_ids + self.certificate = certificate + self.query = query + self.header = header + self.authorization = authorization + + +class BackendPoolItem(_serialization.Model): + """Backend pool service information. + + All required parameters must be populated in order to send to server. + + :ivar id: The unique ARM id of the backend entity. The ARM id should refer to an already + existing backend entity. Required. + :vartype id: str + :ivar weight: The weight of the backend entity in the backend pool. Must be between 0 and 100. + It can be also null if the value not specified. + :vartype weight: int + :ivar priority: The priority of the backend entity in the backend pool. Must be between 0 and + 100. It can be also null if the value not specified. + :vartype priority: int + """ + + _validation = { + "id": {"required": True}, + "weight": {"maximum": 100, "minimum": 0}, + "priority": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "weight": {"key": "weight", "type": "int"}, + "priority": {"key": "priority", "type": "int"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + weight: Optional[int] = None, + priority: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The unique ARM id of the backend entity. The ARM id should refer to an already + existing backend entity. Required. + :paramtype id: str + :keyword weight: The weight of the backend entity in the backend pool. Must be between 0 and + 100. It can be also null if the value not specified. + :paramtype weight: int + :keyword priority: The priority of the backend entity in the backend pool. Must be between 0 + and 100. It can be also null if the value not specified. + :paramtype priority: int + """ + super().__init__(**kwargs) + self.id = id + self.weight = weight + self.priority = priority class BackendProperties(_serialization.Model): @@ -7522,6 +8695,26 @@ def __init__( self.server_x509_names = server_x509_names +class BackendSubnetConfiguration(_serialization.Model): + """Information regarding how the subnet to which the gateway should be injected. + + :ivar id: The ARM ID of the subnet in which the backend systems are hosted. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: The ARM ID of the subnet in which the backend systems are hosted. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + class BackendTlsProperties(_serialization.Model): """Properties controlling TLS Certificate Validation. @@ -7554,7 +8747,7 @@ def __init__( self.validate_certificate_name = validate_certificate_name -class BackendUpdateParameterProperties(BackendBaseParameters): +class BackendUpdateParameterProperties(BackendBaseParameters): # pylint: disable=too-many-instance-attributes """Parameters supplied to the Update Backend operation. :ivar title: Backend Title. @@ -7572,6 +8765,13 @@ class BackendUpdateParameterProperties(BackendBaseParameters): :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :ivar circuit_breaker: Backend Circuit Breaker Configuration. + :vartype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :ivar pool: + :vartype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :ivar type: Type of the backend. A backend can be either Single or Pool. Known values are: + "Single" and "Pool". + :vartype type: str or ~azure.mgmt.apimanagement.models.BackendType :ivar url: Runtime Url of the Backend. :vartype url: str :ivar protocol: Backend communication protocol. Known values are: "http" and "soap". @@ -7593,6 +8793,9 @@ class BackendUpdateParameterProperties(BackendBaseParameters): "credentials": {"key": "credentials", "type": "BackendCredentialsContract"}, "proxy": {"key": "proxy", "type": "BackendProxyContract"}, "tls": {"key": "tls", "type": "BackendTlsProperties"}, + "circuit_breaker": {"key": "circuitBreaker", "type": "BackendCircuitBreaker"}, + "pool": {"key": "pool", "type": "BackendBaseParametersPool"}, + "type": {"key": "type", "type": "str"}, "url": {"key": "url", "type": "str"}, "protocol": {"key": "protocol", "type": "str"}, } @@ -7607,6 +8810,9 @@ def __init__( credentials: Optional["_models.BackendCredentialsContract"] = None, proxy: Optional["_models.BackendProxyContract"] = None, tls: Optional["_models.BackendTlsProperties"] = None, + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = None, + pool: Optional["_models.BackendBaseParametersPool"] = None, + type: Optional[Union[str, "_models.BackendType"]] = None, url: Optional[str] = None, protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs: Any @@ -7627,6 +8833,13 @@ def __init__( :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :keyword circuit_breaker: Backend Circuit Breaker Configuration. + :paramtype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :keyword pool: + :paramtype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :keyword type: Type of the backend. A backend can be either Single or Pool. Known values are: + "Single" and "Pool". + :paramtype type: str or ~azure.mgmt.apimanagement.models.BackendType :keyword url: Runtime Url of the Backend. :paramtype url: str :keyword protocol: Backend communication protocol. Known values are: "http" and "soap". @@ -7640,13 +8853,16 @@ def __init__( credentials=credentials, proxy=proxy, tls=tls, + circuit_breaker=circuit_breaker, + pool=pool, + type=type, **kwargs ) self.url = url self.protocol = protocol -class BackendUpdateParameters(_serialization.Model): +class BackendUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Backend update parameters. :ivar title: Backend Title. @@ -7664,6 +8880,13 @@ class BackendUpdateParameters(_serialization.Model): :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :ivar circuit_breaker: Backend Circuit Breaker Configuration. + :vartype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :ivar pool: + :vartype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :ivar type: Type of the backend. A backend can be either Single or Pool. Known values are: + "Single" and "Pool". + :vartype type: str or ~azure.mgmt.apimanagement.models.BackendType :ivar url: Runtime Url of the Backend. :vartype url: str :ivar protocol: Backend communication protocol. Known values are: "http" and "soap". @@ -7685,6 +8908,9 @@ class BackendUpdateParameters(_serialization.Model): "credentials": {"key": "properties.credentials", "type": "BackendCredentialsContract"}, "proxy": {"key": "properties.proxy", "type": "BackendProxyContract"}, "tls": {"key": "properties.tls", "type": "BackendTlsProperties"}, + "circuit_breaker": {"key": "properties.circuitBreaker", "type": "BackendCircuitBreaker"}, + "pool": {"key": "properties.pool", "type": "BackendBaseParametersPool"}, + "type": {"key": "properties.type", "type": "str"}, "url": {"key": "properties.url", "type": "str"}, "protocol": {"key": "properties.protocol", "type": "str"}, } @@ -7699,6 +8925,9 @@ def __init__( credentials: Optional["_models.BackendCredentialsContract"] = None, proxy: Optional["_models.BackendProxyContract"] = None, tls: Optional["_models.BackendTlsProperties"] = None, + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = None, + pool: Optional["_models.BackendBaseParametersPool"] = None, + type: Optional[Union[str, "_models.BackendType"]] = None, url: Optional[str] = None, protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs: Any @@ -7719,6 +8948,13 @@ def __init__( :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :keyword circuit_breaker: Backend Circuit Breaker Configuration. + :paramtype circuit_breaker: ~azure.mgmt.apimanagement.models.BackendCircuitBreaker + :keyword pool: + :paramtype pool: ~azure.mgmt.apimanagement.models.BackendBaseParametersPool + :keyword type: Type of the backend. A backend can be either Single or Pool. Known values are: + "Single" and "Pool". + :paramtype type: str or ~azure.mgmt.apimanagement.models.BackendType :keyword url: Runtime Url of the Backend. :paramtype url: str :keyword protocol: Backend communication protocol. Known values are: "http" and "soap". @@ -7732,6 +8968,9 @@ def __init__( self.credentials = credentials self.proxy = proxy self.tls = tls + self.circuit_breaker = circuit_breaker + self.pool = pool + self.type = type self.url = url self.protocol = protocol @@ -8169,6 +9408,110 @@ def __init__(self, *, expiry: datetime.datetime, thumbprint: str, subject: str, self.subject = subject +class CircuitBreakerFailureCondition(_serialization.Model): + """The trip conditions of the circuit breaker. + + :ivar count: The threshold for opening the circuit. + :vartype count: int + :ivar percentage: The threshold for opening the circuit. + :vartype percentage: int + :ivar interval: The interval during which the failures are counted. + :vartype interval: ~datetime.timedelta + :ivar status_code_ranges: The status code ranges which are considered as failure. + :vartype status_code_ranges: list[~azure.mgmt.apimanagement.models.FailureStatusCodeRange] + :ivar error_reasons: The error reasons which are considered as failure. + :vartype error_reasons: list[str] + """ + + _validation = { + "status_code_ranges": {"max_items": 10, "min_items": 0}, + "error_reasons": {"max_items": 10, "min_items": 0}, + } + + _attribute_map = { + "count": {"key": "count", "type": "int"}, + "percentage": {"key": "percentage", "type": "int"}, + "interval": {"key": "interval", "type": "duration"}, + "status_code_ranges": {"key": "statusCodeRanges", "type": "[FailureStatusCodeRange]"}, + "error_reasons": {"key": "errorReasons", "type": "[str]"}, + } + + def __init__( + self, + *, + count: Optional[int] = None, + percentage: Optional[int] = None, + interval: Optional[datetime.timedelta] = None, + status_code_ranges: Optional[List["_models.FailureStatusCodeRange"]] = None, + error_reasons: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword count: The threshold for opening the circuit. + :paramtype count: int + :keyword percentage: The threshold for opening the circuit. + :paramtype percentage: int + :keyword interval: The interval during which the failures are counted. + :paramtype interval: ~datetime.timedelta + :keyword status_code_ranges: The status code ranges which are considered as failure. + :paramtype status_code_ranges: list[~azure.mgmt.apimanagement.models.FailureStatusCodeRange] + :keyword error_reasons: The error reasons which are considered as failure. + :paramtype error_reasons: list[str] + """ + super().__init__(**kwargs) + self.count = count + self.percentage = percentage + self.interval = interval + self.status_code_ranges = status_code_ranges + self.error_reasons = error_reasons + + +class CircuitBreakerRule(_serialization.Model): + """Rule configuration to trip the backend. + + :ivar name: The rule name. + :vartype name: str + :ivar failure_condition: The conditions for tripping the circuit breaker. + :vartype failure_condition: ~azure.mgmt.apimanagement.models.CircuitBreakerFailureCondition + :ivar trip_duration: The duration for which the circuit will be tripped. + :vartype trip_duration: ~datetime.timedelta + :ivar accept_retry_after: flag to accept Retry-After header from the backend. + :vartype accept_retry_after: bool + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "failure_condition": {"key": "failureCondition", "type": "CircuitBreakerFailureCondition"}, + "trip_duration": {"key": "tripDuration", "type": "duration"}, + "accept_retry_after": {"key": "acceptRetryAfter", "type": "bool"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + failure_condition: Optional["_models.CircuitBreakerFailureCondition"] = None, + trip_duration: Optional[datetime.timedelta] = None, + accept_retry_after: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The rule name. + :paramtype name: str + :keyword failure_condition: The conditions for tripping the circuit breaker. + :paramtype failure_condition: ~azure.mgmt.apimanagement.models.CircuitBreakerFailureCondition + :keyword trip_duration: The duration for which the circuit will be tripped. + :paramtype trip_duration: ~datetime.timedelta + :keyword accept_retry_after: flag to accept Retry-After header from the backend. + :paramtype accept_retry_after: bool + """ + super().__init__(**kwargs) + self.name = name + self.failure_condition = failure_condition + self.trip_duration = trip_duration + self.accept_retry_after = accept_retry_after + + class ClientSecretContract(_serialization.Model): """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. @@ -8189,6 +9532,32 @@ def __init__(self, *, client_secret: Optional[str] = None, **kwargs: Any) -> Non self.client_secret = client_secret +class ConfigurationApi(_serialization.Model): + """Information regarding the Configuration API of the API Management service. + + :ivar legacy_api: Indication whether or not the legacy Configuration API (v1) should be exposed + on the API Management service. Value is optional but must be 'Enabled' or 'Disabled'. If + 'Disabled', legacy Configuration API (v1) will not be available for self-hosted gateways. + Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". + :vartype legacy_api: str or ~azure.mgmt.apimanagement.models.LegacyApiState + """ + + _attribute_map = { + "legacy_api": {"key": "legacyApi", "type": "str"}, + } + + def __init__(self, *, legacy_api: Union[str, "_models.LegacyApiState"] = "Enabled", **kwargs: Any) -> None: + """ + :keyword legacy_api: Indication whether or not the legacy Configuration API (v1) should be + exposed on the API Management service. Value is optional but must be 'Enabled' or 'Disabled'. + If 'Disabled', legacy Configuration API (v1) will not be available for self-hosted gateways. + Default value is 'Enabled'. Known values are: "Enabled" and "Disabled". + :paramtype legacy_api: str or ~azure.mgmt.apimanagement.models.LegacyApiState + """ + super().__init__(**kwargs) + self.legacy_api = legacy_api + + class ConnectivityCheckRequest(_serialization.Model): """A request to perform the connectivity check operation on a API Management service. @@ -9150,6 +10519,125 @@ def __init__( self.metrics = metrics +class DiagnosticUpdateContract(ProxyResource): # pylint: disable=too-many-instance-attributes + """Diagnostic details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar always_log: Specifies for what type of messages sampling settings should not apply. + "allErrors" + :vartype always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog + :ivar logger_id: Resource Id of a target logger. + :vartype logger_id: str + :ivar sampling: Sampling settings for Diagnostic. + :vartype sampling: ~azure.mgmt.apimanagement.models.SamplingSettings + :ivar frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + :vartype frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :ivar backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. + :vartype backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :ivar log_client_ip: Log the ClientIP. Default is false. + :vartype log_client_ip: bool + :ivar http_correlation_protocol: Sets correlation protocol to use for Application Insights + diagnostics. Known values are: "None", "Legacy", and "W3C". + :vartype http_correlation_protocol: str or + ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol + :ivar verbosity: The verbosity level applied to traces emitted by trace policies. Known values + are: "verbose", "information", and "error". + :vartype verbosity: str or ~azure.mgmt.apimanagement.models.Verbosity + :ivar operation_name_format: The format of the Operation Name for Application Insights + telemetries. Default is Name. Known values are: "Name" and "Url". + :vartype operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat + :ivar metrics: Emit custom metrics via emit-metric policy. Applicable only to Application + Insights diagnostic settings. + :vartype metrics: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "always_log": {"key": "properties.alwaysLog", "type": "str"}, + "logger_id": {"key": "properties.loggerId", "type": "str"}, + "sampling": {"key": "properties.sampling", "type": "SamplingSettings"}, + "frontend": {"key": "properties.frontend", "type": "PipelineDiagnosticSettings"}, + "backend": {"key": "properties.backend", "type": "PipelineDiagnosticSettings"}, + "log_client_ip": {"key": "properties.logClientIp", "type": "bool"}, + "http_correlation_protocol": {"key": "properties.httpCorrelationProtocol", "type": "str"}, + "verbosity": {"key": "properties.verbosity", "type": "str"}, + "operation_name_format": {"key": "properties.operationNameFormat", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "bool"}, + } + + def __init__( + self, + *, + always_log: Optional[Union[str, "_models.AlwaysLog"]] = None, + logger_id: Optional[str] = None, + sampling: Optional["_models.SamplingSettings"] = None, + frontend: Optional["_models.PipelineDiagnosticSettings"] = None, + backend: Optional["_models.PipelineDiagnosticSettings"] = None, + log_client_ip: Optional[bool] = None, + http_correlation_protocol: Optional[Union[str, "_models.HttpCorrelationProtocol"]] = None, + verbosity: Optional[Union[str, "_models.Verbosity"]] = None, + operation_name_format: Optional[Union[str, "_models.OperationNameFormat"]] = None, + metrics: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword always_log: Specifies for what type of messages sampling settings should not apply. + "allErrors" + :paramtype always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog + :keyword logger_id: Resource Id of a target logger. + :paramtype logger_id: str + :keyword sampling: Sampling settings for Diagnostic. + :paramtype sampling: ~azure.mgmt.apimanagement.models.SamplingSettings + :keyword frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + :paramtype frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :keyword backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. + :paramtype backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :keyword log_client_ip: Log the ClientIP. Default is false. + :paramtype log_client_ip: bool + :keyword http_correlation_protocol: Sets correlation protocol to use for Application Insights + diagnostics. Known values are: "None", "Legacy", and "W3C". + :paramtype http_correlation_protocol: str or + ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol + :keyword verbosity: The verbosity level applied to traces emitted by trace policies. Known + values are: "verbose", "information", and "error". + :paramtype verbosity: str or ~azure.mgmt.apimanagement.models.Verbosity + :keyword operation_name_format: The format of the Operation Name for Application Insights + telemetries. Default is Name. Known values are: "Name" and "Url". + :paramtype operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat + :keyword metrics: Emit custom metrics via emit-metric policy. Applicable only to Application + Insights diagnostic settings. + :paramtype metrics: bool + """ + super().__init__(**kwargs) + self.always_log = always_log + self.logger_id = logger_id + self.sampling = sampling + self.frontend = frontend + self.backend = backend + self.log_client_ip = log_client_ip + self.http_correlation_protocol = http_correlation_protocol + self.verbosity = verbosity + self.operation_name_format = operation_name_format + self.metrics = metrics + + class DocumentationCollection(_serialization.Model): """Paged Documentation list representation. @@ -9507,30 +10995,101 @@ def __init__( self.endpoint_details = endpoint_details -class EndpointDetail(_serialization.Model): - """Current TCP connectivity information from the Api Management Service to a single endpoint. +class EndpointDetail(_serialization.Model): + """Current TCP connectivity information from the Api Management Service to a single endpoint. + + :ivar port: The port an endpoint is connected to. + :vartype port: int + :ivar region: The region of the dependency. + :vartype region: str + """ + + _attribute_map = { + "port": {"key": "port", "type": "int"}, + "region": {"key": "region", "type": "str"}, + } + + def __init__(self, *, port: Optional[int] = None, region: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword port: The port an endpoint is connected to. + :paramtype port: int + :keyword region: The region of the dependency. + :paramtype region: str + """ + super().__init__(**kwargs) + self.port = port + self.region = region + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. - :ivar port: The port an endpoint is connected to. - :vartype port: int - :ivar region: The region of the dependency. - :vartype region: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.apimanagement.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.apimanagement.models.ErrorAdditionalInfo] """ + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + _attribute_map = { - "port": {"key": "port", "type": "int"}, - "region": {"key": "region", "type": "str"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__(self, *, port: Optional[int] = None, region: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword port: The port an endpoint is connected to. - :paramtype port: int - :keyword region: The region of the dependency. - :paramtype region: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.port = port - self.region = region + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None class ErrorFieldContract(_serialization.Model): @@ -9568,44 +11127,24 @@ def __init__( class ErrorResponse(_serialization.Model): - """Error Response. + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). - :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :vartype code: str - :ivar message: Human-readable representation of the error. - :vartype message: str - :ivar details: The list of invalid fields send in request, in case of validation error. - :vartype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] + :ivar error: The error object. + :vartype error: ~azure.mgmt.apimanagement.models.ErrorDetail """ _attribute_map = { - "code": {"key": "error.code", "type": "str"}, - "message": {"key": "error.message", "type": "str"}, - "details": {"key": "error.details", "type": "[ErrorFieldContract]"}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - details: Optional[List["_models.ErrorFieldContract"]] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ - :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :paramtype code: str - :keyword message: Human-readable representation of the error. - :paramtype message: str - :keyword details: The list of invalid fields send in request, in case of validation error. - :paramtype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] + :keyword error: The error object. + :paramtype error: ~azure.mgmt.apimanagement.models.ErrorDetail """ super().__init__(**kwargs) - self.code = code - self.message = message - self.details = details + self.error = error class ErrorResponseBody(_serialization.Model): @@ -9649,6 +11188,67 @@ def __init__( self.details = details +class FailureStatusCodeRange(_serialization.Model): + """The failure http status code range. + + :ivar min: The minimum http status code. + :vartype min: int + :ivar max: The maximum http status code. + :vartype max: int + """ + + _validation = { + "min": {"maximum": 599, "minimum": 200}, + "max": {"maximum": 599, "minimum": 200}, + } + + _attribute_map = { + "min": {"key": "min", "type": "int"}, + "max": {"key": "max", "type": "int"}, + } + + def __init__( + self, + *, + min: Optional[int] = None, # pylint: disable=redefined-builtin + max: Optional[int] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: + """ + :keyword min: The minimum http status code. + :paramtype min: int + :keyword max: The maximum http status code. + :paramtype max: int + """ + super().__init__(**kwargs) + self.min = min + self.max = max + + +class FrontendConfiguration(_serialization.Model): + """Information regarding how the gateway should be exposed. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar default_hostname: The default hostname of the data-plane gateway to which requests can be + sent. This is only applicable for API gateway with Standard SKU. + :vartype default_hostname: str + """ + + _validation = { + "default_hostname": {"readonly": True}, + } + + _attribute_map = { + "default_hostname": {"key": "defaultHostname", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.default_hostname = None + + class GatewayCertificateAuthorityCollection(_serialization.Model): """Paged Gateway certificate authority list representation. @@ -9751,6 +11351,30 @@ def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: self.next_link = None +class GatewayConfigurationApi(_serialization.Model): + """Information regarding the Configuration API of the API Management gateway. This is only + applicable for API gateway with Standard SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar hostname: Hostname to which the agent connects to propagate configuration to the cloud. + :vartype hostname: str + """ + + _validation = { + "hostname": {"readonly": True}, + } + + _attribute_map = { + "hostname": {"key": "hostname", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.hostname = None + + class GatewayContract(ProxyResource): """Gateway details. @@ -9803,6 +11427,26 @@ def __init__( self.description = description +class GatewayDebugCredentialsContract(_serialization.Model): + """Gateway debug credentials. + + :ivar token: Gateway debug token. + :vartype token: str + """ + + _attribute_map = { + "token": {"key": "token", "type": "str"}, + } + + def __init__(self, *, token: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword token: Gateway debug token. + :paramtype token: str + """ + super().__init__(**kwargs) + self.token = token + + class GatewayHostnameConfigurationCollection(_serialization.Model): """Paged Gateway hostname configuration list representation. @@ -9962,8 +11606,206 @@ def __init__(self, *, primary: Optional[str] = None, secondary: Optional[str] = :paramtype secondary: str """ super().__init__(**kwargs) - self.primary = primary - self.secondary = secondary + self.primary = primary + self.secondary = secondary + + +class GatewayListDebugCredentialsContract(_serialization.Model): + """List debug credentials properties. + + All required parameters must be populated in order to send to server. + + :ivar credentials_expire_after: Credentials expiration in ISO8601 format. Maximum duration of + the credentials is PT1H. When property is not specified, them value PT1H is used. + :vartype credentials_expire_after: ~datetime.timedelta + :ivar purposes: Purposes of debug credential. Required. + :vartype purposes: list[str or + ~azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContractPurpose] + :ivar api_id: Full resource Id of an API. Required. + :vartype api_id: str + """ + + _validation = { + "purposes": {"required": True}, + "api_id": {"required": True}, + } + + _attribute_map = { + "credentials_expire_after": {"key": "credentialsExpireAfter", "type": "duration"}, + "purposes": {"key": "purposes", "type": "[str]"}, + "api_id": {"key": "apiId", "type": "str"}, + } + + def __init__( + self, + *, + purposes: List[Union[str, "_models.GatewayListDebugCredentialsContractPurpose"]], + api_id: str, + credentials_expire_after: Optional[datetime.timedelta] = None, + **kwargs: Any + ) -> None: + """ + :keyword credentials_expire_after: Credentials expiration in ISO8601 format. Maximum duration + of the credentials is PT1H. When property is not specified, them value PT1H is used. + :paramtype credentials_expire_after: ~datetime.timedelta + :keyword purposes: Purposes of debug credential. Required. + :paramtype purposes: list[str or + ~azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContractPurpose] + :keyword api_id: Full resource Id of an API. Required. + :paramtype api_id: str + """ + super().__init__(**kwargs) + self.credentials_expire_after = credentials_expire_after + self.purposes = purposes + self.api_id = api_id + + +class GatewayListTraceContract(_serialization.Model): + """List trace properties. + + :ivar trace_id: Trace id. + :vartype trace_id: str + """ + + _attribute_map = { + "trace_id": {"key": "traceId", "type": "str"}, + } + + def __init__(self, *, trace_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword trace_id: Trace id. + :paramtype trace_id: str + """ + super().__init__(**kwargs) + self.trace_id = trace_id + + +class GatewayResourceSkuResult(_serialization.Model): + """Describes an available API Management gateway SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :ivar sku: Specifies API Management gateway SKU. + :vartype sku: ~azure.mgmt.apimanagement.models.GatewaySku + :ivar capacity: Specifies the number of API Management gateway units. + :vartype capacity: ~azure.mgmt.apimanagement.models.GatewaySkuCapacity + """ + + _validation = { + "resource_type": {"readonly": True}, + "sku": {"readonly": True}, + "capacity": {"readonly": True}, + } + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "GatewaySku"}, + "capacity": {"key": "capacity", "type": "GatewaySkuCapacity"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.resource_type = None + self.sku = None + self.capacity = None + + +class GatewayResourceSkuResults(_serialization.Model): + """The API Management gateway SKUs operation response. + + All required parameters must be populated in order to send to server. + + :ivar value: The list of skus available for the gateway. Required. + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayResourceSkuResult] + :ivar next_link: The uri to fetch the next page of API Management gateway Skus. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[GatewayResourceSkuResult]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.GatewayResourceSkuResult"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of skus available for the gateway. Required. + :paramtype value: list[~azure.mgmt.apimanagement.models.GatewayResourceSkuResult] + :keyword next_link: The uri to fetch the next page of API Management gateway Skus. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GatewaySku(_serialization.Model): + """Describes an available API Management SKU for gateways. + + :ivar name: Name of the Sku. Known values are: "Standard", "WorkspaceGatewayStandard", and + "WorkspaceGatewayPremium". + :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Optional[Union[str, "_models.SkuType"]] = None, **kwargs: Any) -> None: + """ + :keyword name: Name of the Sku. Known values are: "Standard", "WorkspaceGatewayStandard", and + "WorkspaceGatewayPremium". + :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType + """ + super().__init__(**kwargs) + self.name = name + + +class GatewaySkuCapacity(_serialization.Model): + """Describes scaling information of a SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar minimum: The minimum capacity. + :vartype minimum: int + :ivar maximum: The maximum capacity that can be set. + :vartype maximum: int + :ivar default: The default capacity. + :vartype default: int + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", + "Manual", and "None". + :vartype scale_type: str or ~azure.mgmt.apimanagement.models.GatewaySkuCapacityScaleType + """ + + _validation = { + "minimum": {"readonly": True}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, + } + + _attribute_map = { + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.minimum = None + self.maximum = None + self.default = None + self.scale_type = None class GatewayTokenContract(_serialization.Model): @@ -10101,12 +11943,15 @@ class GlobalSchemaContract(ProxyResource): :vartype value: any :ivar document: Global Schema document object for json-based schema formats(e.g. json schema). :vartype document: JSON + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -10117,6 +11962,7 @@ class GlobalSchemaContract(ProxyResource): "description": {"key": "properties.description", "type": "str"}, "value": {"key": "properties.value", "type": "object"}, "document": {"key": "properties.document", "type": "object"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -10144,6 +11990,7 @@ def __init__( self.description = description self.value = value self.document = document + self.provisioning_state = None class GroupCollection(_serialization.Model): @@ -10209,7 +12056,7 @@ class GroupContract(ProxyResource): :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.GroupType :ivar external_id: For external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory - ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + ``aad://.onmicrosoft.com/groups/``\\ ; otherwise the value is null. :vartype external_id: str """ @@ -10252,7 +12099,7 @@ def __init__( :paramtype type_properties_type: str or ~azure.mgmt.apimanagement.models.GroupType :keyword external_id: For external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory - ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + ``aad://.onmicrosoft.com/groups/``\\ ; otherwise the value is null. :paramtype external_id: str """ super().__init__(**kwargs) @@ -10281,7 +12128,7 @@ class GroupContractProperties(_serialization.Model): :vartype type: str or ~azure.mgmt.apimanagement.models.GroupType :ivar external_id: For external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory - ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + ``aad://.onmicrosoft.com/groups/``\\ ; otherwise the value is null. :vartype external_id: str """ @@ -10317,7 +12164,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.apimanagement.models.GroupType :keyword external_id: For external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory - ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + ``aad://.onmicrosoft.com/groups/``\\ ; otherwise the value is null. :paramtype external_id: str """ super().__init__(**kwargs) @@ -10339,7 +12186,7 @@ class GroupCreateParameters(_serialization.Model): :vartype type: str or ~azure.mgmt.apimanagement.models.GroupType :ivar external_id: Identifier of the external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory - ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + ``aad://.onmicrosoft.com/groups/``\\ ; otherwise the value is null. :vartype external_id: str """ @@ -10372,7 +12219,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.apimanagement.models.GroupType :keyword external_id: Identifier of the external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory - ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + ``aad://.onmicrosoft.com/groups/``\\ ; otherwise the value is null. :paramtype external_id: str """ super().__init__(**kwargs) @@ -10393,7 +12240,7 @@ class GroupUpdateParameters(_serialization.Model): :vartype type: str or ~azure.mgmt.apimanagement.models.GroupType :ivar external_id: Identifier of the external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory - ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + ``aad://.onmicrosoft.com/groups/``\\ ; otherwise the value is null. :vartype external_id: str """ @@ -10426,7 +12273,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.apimanagement.models.GroupType :keyword external_id: Identifier of the external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory - ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + ``aad://.onmicrosoft.com/groups/``\\ ; otherwise the value is null. :paramtype external_id: str """ super().__init__(**kwargs) @@ -10442,7 +12289,7 @@ class HostnameConfiguration(_serialization.Model): # pylint: disable=too-many-i All required parameters must be populated in order to send to server. :ivar type: Hostname type. Required. Known values are: "Proxy", "Portal", "Management", "Scm", - and "DeveloperPortal". + "DeveloperPortal", and "ConfigurationApi". :vartype type: str or ~azure.mgmt.apimanagement.models.HostnameType :ivar host_name: Hostname to configure on the Api Management service. Required. :vartype host_name: str @@ -10514,7 +12361,7 @@ def __init__( ) -> None: """ :keyword type: Hostname type. Required. Known values are: "Proxy", "Portal", "Management", - "Scm", and "DeveloperPortal". + "Scm", "DeveloperPortal", and "ConfigurationApi". :paramtype type: str or ~azure.mgmt.apimanagement.models.HostnameType :keyword host_name: Hostname to configure on the Api Management service. Required. :paramtype host_name: str @@ -12388,6 +14235,28 @@ def __init__( self.is_buffered = is_buffered +class MigrateToStv2Contract(_serialization.Model): + """Describes an available API Management SKU. + + :ivar mode: Mode of Migration to stv2. Default is PreserveIp. Known values are: "PreserveIp" + and "NewIP". + :vartype mode: str or ~azure.mgmt.apimanagement.models.MigrateToStv2Mode + """ + + _attribute_map = { + "mode": {"key": "mode", "type": "str"}, + } + + def __init__(self, *, mode: Optional[Union[str, "_models.MigrateToStv2Mode"]] = None, **kwargs: Any) -> None: + """ + :keyword mode: Mode of Migration to stv2. Default is PreserveIp. Known values are: "PreserveIp" + and "NewIP". + :paramtype mode: str or ~azure.mgmt.apimanagement.models.MigrateToStv2Mode + """ + super().__init__(**kwargs) + self.mode = mode + + class NamedValueCollection(_serialization.Model): """Paged NamedValue list representation. @@ -12454,6 +14323,8 @@ class NamedValueContract(ProxyResource): :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _validation = { @@ -12463,6 +14334,7 @@ class NamedValueContract(ProxyResource): "tags": {"max_items": 32, "min_items": 0}, "display_name": {"max_length": 256, "min_length": 1, "pattern": r"^[A-Za-z0-9-._]+$"}, "value": {"max_length": 4096}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -12474,6 +14346,7 @@ class NamedValueContract(ProxyResource): "display_name": {"key": "properties.displayName", "type": "str"}, "value": {"key": "properties.value", "type": "str"}, "key_vault": {"key": "properties.keyVault", "type": "KeyVaultContractProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -12508,6 +14381,7 @@ def __init__( self.display_name = display_name self.value = value self.key_vault = key_vault + self.provisioning_state = None class NamedValueEntityBaseParameters(_serialization.Model): @@ -12545,6 +14419,8 @@ def __init__(self, *, tags: Optional[List[str]] = None, secret: Optional[bool] = class NamedValueContractProperties(NamedValueEntityBaseParameters): """NamedValue Contract properties. + Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to server. :ivar tags: Optional tags that when provided can be used to filter the NamedValue list. @@ -12561,12 +14437,15 @@ class NamedValueContractProperties(NamedValueEntityBaseParameters): :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _validation = { "tags": {"max_items": 32, "min_items": 0}, "display_name": {"required": True, "max_length": 256, "min_length": 1, "pattern": r"^[A-Za-z0-9-._]+$"}, "value": {"max_length": 4096}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -12575,6 +14454,7 @@ class NamedValueContractProperties(NamedValueEntityBaseParameters): "display_name": {"key": "displayName", "type": "str"}, "value": {"key": "value", "type": "str"}, "key_vault": {"key": "keyVault", "type": "KeyVaultContractProperties"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -12607,6 +14487,7 @@ def __init__( self.display_name = display_name self.value = value self.key_vault = key_vault + self.provisioning_state = None class NamedValueCreateContract(ProxyResource): @@ -13880,6 +15761,95 @@ def __init__( self.object_key = object_key +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.apimanagement.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.apimanagement.models.ErrorDetail + """ + + _validation = { + "resource_id": {"readonly": True}, + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "operations": {"key": "operations", "type": "[OperationStatusResult]"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[List["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: list[~azure.mgmt.apimanagement.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.apimanagement.models.ErrorDetail + """ + super().__init__(**kwargs) + self.id = id + self.resource_id = None + self.name = name + self.status = status + self.percent_complete = percent_complete + self.start_time = start_time + self.end_time = end_time + self.operations = operations + self.error = error + + class OperationTagResourceContractProperties(_serialization.Model): """Operation Entity contract Properties. @@ -14543,12 +16513,227 @@ def __init__( """ super().__init__(**kwargs) self.value = value - self.count = count + self.count = count + self.next_link = next_link + + +class PolicyFragmentContract(ProxyResource): + """Policy fragment contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar value: Contents of the policy fragment. + :vartype value: str + :ivar description: Policy fragment description. + :vartype description: str + :ivar format: Format of the policy fragment content. Known values are: "xml" and "rawxml". + :vartype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "description": {"max_length": 1000}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "properties.value", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "format": {"key": "properties.format", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + description: Optional[str] = None, + format: Optional[Union[str, "_models.PolicyFragmentContentFormat"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Contents of the policy fragment. + :paramtype value: str + :keyword description: Policy fragment description. + :paramtype description: str + :keyword format: Format of the policy fragment content. Known values are: "xml" and "rawxml". + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + """ + super().__init__(**kwargs) + self.value = value + self.description = description + self.format = format + self.provisioning_state = None + + +class PolicyRestrictionCollection(_serialization.Model): + """The response of the get policy restrictions operation. + + :ivar value: + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyRestrictionContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PolicyRestrictionContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PolicyRestrictionContract"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyRestrictionContract] + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyRestrictionContract(ProxyResource): + """Policy restriction contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar scope: Path to the policy document. + :vartype scope: str + :ivar require_base: Indicates if base policy should be enforced for the policy document. Known + values are: "true" and "false". + :vartype require_base: str or ~azure.mgmt.apimanagement.models.PolicyRestrictionRequireBase + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "require_base": {"key": "properties.requireBase", "type": "str"}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + require_base: Union[str, "_models.PolicyRestrictionRequireBase"] = "false", + **kwargs: Any + ) -> None: + """ + :keyword scope: Path to the policy document. + :paramtype scope: str + :keyword require_base: Indicates if base policy should be enforced for the policy document. + Known values are: "true" and "false". + :paramtype require_base: str or ~azure.mgmt.apimanagement.models.PolicyRestrictionRequireBase + """ + super().__init__(**kwargs) + self.scope = scope + self.require_base = require_base + + +class PolicyRestrictionUpdateContract(_serialization.Model): + """Policy restriction contract details. + + :ivar scope: Path to the policy document. + :vartype scope: str + :ivar require_base: Indicates if base policy should be enforced for the policy document. Known + values are: "true" and "false". + :vartype require_base: str or ~azure.mgmt.apimanagement.models.PolicyRestrictionRequireBase + """ + + _attribute_map = { + "scope": {"key": "properties.scope", "type": "str"}, + "require_base": {"key": "properties.requireBase", "type": "str"}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + require_base: Union[str, "_models.PolicyRestrictionRequireBase"] = "false", + **kwargs: Any + ) -> None: + """ + :keyword scope: Path to the policy document. + :paramtype scope: str + :keyword require_base: Indicates if base policy should be enforced for the policy document. + Known values are: "true" and "false". + :paramtype require_base: str or ~azure.mgmt.apimanagement.models.PolicyRestrictionRequireBase + """ + super().__init__(**kwargs) + self.scope = scope + self.require_base = require_base + + +class PolicyWithComplianceCollection(_serialization.Model): + """The response of the list policy operation. + + :ivar value: Policy Contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyWithComplianceContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PolicyWithComplianceContract]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PolicyWithComplianceContract"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Policy Contract value. + :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyWithComplianceContract] + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value self.next_link = next_link -class PolicyFragmentContract(ProxyResource): - """Policy fragment contract details. +class PolicyWithComplianceContract(ProxyResource): + """Policy Contract details. Variables are only populated by the server, and will be ignored when sending a request. @@ -14560,50 +16745,44 @@ class PolicyFragmentContract(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar value: Contents of the policy fragment. - :vartype value: str - :ivar description: Policy fragment description. - :vartype description: str - :ivar format: Format of the policy fragment content. Known values are: "xml" and "rawxml". - :vartype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :ivar reference_policy_id: Policy Identifier. + :vartype reference_policy_id: str + :ivar compliance_state: Policy Restriction Compliance State. Known values are: "Pending", + "NonCompliant", and "Compliant". + :vartype compliance_state: str or ~azure.mgmt.apimanagement.models.PolicyComplianceState """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "description": {"max_length": 1000}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "value": {"key": "properties.value", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "format": {"key": "properties.format", "type": "str"}, + "reference_policy_id": {"key": "properties.referencePolicyId", "type": "str"}, + "compliance_state": {"key": "properties.complianceState", "type": "str"}, } def __init__( self, *, - value: Optional[str] = None, - description: Optional[str] = None, - format: Optional[Union[str, "_models.PolicyFragmentContentFormat"]] = None, + reference_policy_id: Optional[str] = None, + compliance_state: Optional[Union[str, "_models.PolicyComplianceState"]] = None, **kwargs: Any ) -> None: """ - :keyword value: Contents of the policy fragment. - :paramtype value: str - :keyword description: Policy fragment description. - :paramtype description: str - :keyword format: Format of the policy fragment content. Known values are: "xml" and "rawxml". - :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :keyword reference_policy_id: Policy Identifier. + :paramtype reference_policy_id: str + :keyword compliance_state: Policy Restriction Compliance State. Known values are: "Pending", + "NonCompliant", and "Compliant". + :paramtype compliance_state: str or ~azure.mgmt.apimanagement.models.PolicyComplianceState """ super().__init__(**kwargs) - self.value = value - self.description = description - self.format = format + self.reference_policy_id = reference_policy_id + self.compliance_state = compliance_state class PortalConfigCollection(_serialization.Model): @@ -14743,7 +16922,7 @@ class PortalConfigCspProperties(_serialization.Model): :vartype mode: str or ~azure.mgmt.apimanagement.models.PortalSettingsCspMode :ivar report_uri: The URLs used by the browser to report CSP violations. :vartype report_uri: list[str] - :ivar allowed_sources: Allowed sources, e.g. ``*.trusted.com``\ , ``trusted.com``\ , + :ivar allowed_sources: Allowed sources, e.g. ``*.trusted.com``\\ , ``trusted.com``\\ , ``https://``. :vartype allowed_sources: list[str] """ @@ -14768,7 +16947,7 @@ def __init__( :paramtype mode: str or ~azure.mgmt.apimanagement.models.PortalSettingsCspMode :keyword report_uri: The URLs used by the browser to report CSP violations. :paramtype report_uri: list[str] - :keyword allowed_sources: Allowed sources, e.g. ``*.trusted.com``\ , ``trusted.com``\ , + :keyword allowed_sources: Allowed sources, e.g. ``*.trusted.com``\\ , ``trusted.com``\\ , ``https://``. :paramtype allowed_sources: list[str] """ @@ -15021,6 +17200,8 @@ class PortalRevisionContract(ProxyResource): :vartype created_date_time: ~datetime.datetime :ivar updated_date_time: Last updated date and time. :vartype updated_date_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _validation = { @@ -15032,6 +17213,7 @@ class PortalRevisionContract(ProxyResource): "status": {"readonly": True}, "created_date_time": {"readonly": True}, "updated_date_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -15044,6 +17226,7 @@ class PortalRevisionContract(ProxyResource): "is_current": {"key": "properties.isCurrent", "type": "bool"}, "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, "updated_date_time": {"key": "properties.updatedDateTime", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__(self, *, description: Optional[str] = None, is_current: Optional[bool] = None, **kwargs: Any) -> None: @@ -15060,6 +17243,7 @@ def __init__(self, *, description: Optional[str] = None, is_current: Optional[bo self.is_current = is_current self.created_date_time = None self.updated_date_time = None + self.provisioning_state = None class PortalSettingsCollection(_serialization.Model): @@ -15577,6 +17761,84 @@ def __init__( self.actions_required = actions_required +class ProductApiLinkCollection(_serialization.Model): + """Paged Product-API link list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ProductApiLinkContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ProductApiLinkContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :keyword count: Total record count number across all pages. + :paramtype count: int + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class ProductApiLinkContract(ProxyResource): + """Product-API link details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar api_id: Full resource Id of an API. + :vartype api_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "api_id": {"key": "properties.apiId", "type": "str"}, + } + + def __init__(self, *, api_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword api_id: Full resource Id of an API. + :paramtype api_id: str + """ + super().__init__(**kwargs) + self.api_id = api_id + + class ProductCollection(_serialization.Model): """Paged Products list representation. @@ -15928,6 +18190,84 @@ def __init__( self.display_name = display_name +class ProductGroupLinkCollection(_serialization.Model): + """Paged Product-group link list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ProductGroupLinkContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ProductGroupLinkContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :keyword count: Total record count number across all pages. + :paramtype count: int + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class ProductGroupLinkContract(ProxyResource): + """Product-group link details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar group_id: Full resource Id of a group. + :vartype group_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + } + + def __init__(self, *, group_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword group_id: Full resource Id of a group. + :paramtype group_id: str + """ + super().__init__(**kwargs) + self.group_id = group_id + + class ProductTagResourceContractProperties(ProductEntityBaseParameters): """Product profile. @@ -17731,8 +20071,8 @@ def __init__( class ResourceSku(_serialization.Model): """Describes an available API Management SKU. - :ivar name: Name of the Sku. Known values are: "Developer", "Standard", "Premium", "Basic", - "Consumption", and "Isolated". + :ivar name: Name of the Sku. Known values are: "Standard", "WorkspaceGatewayStandard", and + "WorkspaceGatewayPremium". :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType """ @@ -17742,8 +20082,8 @@ class ResourceSku(_serialization.Model): def __init__(self, *, name: Optional[Union[str, "_models.SkuType"]] = None, **kwargs: Any) -> None: """ - :keyword name: Name of the Sku. Known values are: "Developer", "Standard", "Premium", "Basic", - "Consumption", and "Isolated". + :keyword name: Name of the Sku. Known values are: "Standard", "WorkspaceGatewayStandard", and + "WorkspaceGatewayPremium". :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType """ super().__init__(**kwargs) @@ -18026,8 +20366,11 @@ class SchemaContract(ProxyResource): - ``Swagger`` Schema use ``application/vnd.ms-azure-apim.swagger.definitions+json``
- ``WSDL`` Schema use ``application/vnd.ms-azure-apim.xsd+xml``
- ``OpenApi`` Schema use ``application/vnd.oai.openapi.components+json``
- ``WADL Schema`` use - ``application/vnd.ms-azure-apim.wadl.grammars+xml``. + ``application/vnd.ms-azure-apim.wadl.grammars+xml``
- ``OData Schema`` use + ``application/vnd.ms-azure-apim.odata.schema``
- ``gRPC Schema`` use ``text/protobuf``. :vartype content_type: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str :ivar value: Json escaped string defining the document representing the Schema. Used for schemas other than Swagger/OpenAPI. :vartype value: str @@ -18042,6 +20385,7 @@ class SchemaContract(ProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -18049,6 +20393,7 @@ class SchemaContract(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "content_type": {"key": "properties.contentType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "value": {"key": "properties.document.value", "type": "str"}, "definitions": {"key": "properties.document.definitions", "type": "object"}, "components": {"key": "properties.document.components", "type": "object"}, @@ -18069,7 +20414,8 @@ def __init__( - ``Swagger`` Schema use ``application/vnd.ms-azure-apim.swagger.definitions+json``
- ``WSDL`` Schema use ``application/vnd.ms-azure-apim.xsd+xml``
- ``OpenApi`` Schema use ``application/vnd.oai.openapi.components+json``
- ``WADL Schema`` use - ``application/vnd.ms-azure-apim.wadl.grammars+xml``. + ``application/vnd.ms-azure-apim.wadl.grammars+xml``
- ``OData Schema`` use + ``application/vnd.ms-azure-apim.odata.schema``
- ``gRPC Schema`` use ``text/protobuf``. :paramtype content_type: str :keyword value: Json escaped string defining the document representing the Schema. Used for schemas other than Swagger/OpenAPI. @@ -18083,6 +20429,7 @@ def __init__( """ super().__init__(**kwargs) self.content_type = content_type + self.provisioning_state = None self.value = value self.definitions = definitions self.components = components @@ -18604,40 +20951,118 @@ class SystemData(_serialization.Model): "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TagApiLinkCollection(_serialization.Model): + """Paged Tag-API link list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[TagApiLinkContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.TagApiLinkContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :keyword count: Total record count number across all pages. + :paramtype count: int + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class TagApiLinkContract(ProxyResource): + """Tag-API link details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar api_id: Full resource Id of an API. + :vartype api_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "api_id": {"key": "properties.apiId", "type": "str"}, + } + + def __init__(self, *, api_id: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime + :keyword api_id: Full resource Id of an API. + :paramtype api_id: str """ super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at + self.api_id = api_id class TagCollection(_serialization.Model): @@ -19002,6 +21427,162 @@ def __init__( self.external_docs_description = external_docs_description +class TagOperationLinkCollection(_serialization.Model): + """Paged Tag-operation link list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[TagOperationLinkContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.TagOperationLinkContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :keyword count: Total record count number across all pages. + :paramtype count: int + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class TagOperationLinkContract(ProxyResource): + """Tag-operation link details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar operation_id: Full resource Id of an API operation. + :vartype operation_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "operation_id": {"key": "properties.operationId", "type": "str"}, + } + + def __init__(self, *, operation_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword operation_id: Full resource Id of an API operation. + :paramtype operation_id: str + """ + super().__init__(**kwargs) + self.operation_id = operation_id + + +class TagProductLinkCollection(_serialization.Model): + """Paged Tag-product link list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[TagProductLinkContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.TagProductLinkContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :keyword count: Total record count number across all pages. + :paramtype count: int + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class TagProductLinkContract(ProxyResource): + """Tag-product link details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar product_id: Full resource Id of a product. + :vartype product_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "product_id": {"key": "properties.productId", "type": "str"}, + } + + def __init__(self, *, product_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword product_id: Full resource Id of a product. + :paramtype product_id: str + """ + super().__init__(**kwargs) + self.product_id = product_id + + class TagResourceCollection(_serialization.Model): """Paged Tag list representation. @@ -20274,6 +22855,110 @@ def __init__(self, *, documents: Optional[List["_models.WikiDocumentationContrac self.documents = documents +class WorkspaceCollection(_serialization.Model): + """Paged workspace list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.WorkspaceContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[WorkspaceContract]"}, + "count": {"key": "count", "type": "int"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.WorkspaceContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.WorkspaceContract] + :keyword count: Total record count number across all pages. + :paramtype count: int + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class WorkspaceContract(ProxyResource): + """Workspace details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar display_name: Name of the workspace. + :vartype display_name: str + :ivar description: Description of the workspace. + :vartype description: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + } + + def __init__(self, *, display_name: Optional[str] = None, description: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword display_name: Name of the workspace. + :paramtype display_name: str + :keyword description: Description of the workspace. + :paramtype description: str + """ + super().__init__(**kwargs) + self.display_name = display_name + self.description = description + + +class WorkspaceLinksGateway(_serialization.Model): + """WorkspaceLinksGateway. + + :ivar id: The link to the API Management gateway. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: The link to the API Management gateway. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + class X509CertificateName(_serialization.Model): """Properties of server X509Names. diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/__init__.py index b22d1486cf46..79142cc42a85 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/__init__.py @@ -6,6 +6,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._all_policies_operations import AllPoliciesOperations +from ._api_gateway_operations import ApiGatewayOperations +from ._api_management_gateway_skus_operations import ApiManagementGatewaySkusOperations from ._api_operations import ApiOperations from ._api_revision_operations import ApiRevisionOperations from ._api_release_operations import ApiReleaseOperations @@ -27,11 +30,11 @@ from ._api_wikis_operations import ApiWikisOperations from ._api_export_operations import ApiExportOperations from ._api_version_set_operations import ApiVersionSetOperations -from ._authorization_server_operations import AuthorizationServerOperations from ._authorization_provider_operations import AuthorizationProviderOperations from ._authorization_operations import AuthorizationOperations from ._authorization_login_links_operations import AuthorizationLoginLinksOperations from ._authorization_access_policy_operations import AuthorizationAccessPolicyOperations +from ._authorization_server_operations import AuthorizationServerOperations from ._backend_operations import BackendOperations from ._cache_operations import CacheOperations from ._certificate_operations import CertificateOperations @@ -43,11 +46,13 @@ from ._api_management_service_skus_operations import ApiManagementServiceSkusOperations from ._api_management_service_operations import ApiManagementServiceOperations from ._diagnostic_operations import DiagnosticOperations +from ._documentation_operations import DocumentationOperations from ._email_template_operations import EmailTemplateOperations from ._gateway_operations import GatewayOperations from ._gateway_hostname_configuration_operations import GatewayHostnameConfigurationOperations from ._gateway_api_operations import GatewayApiOperations from ._gateway_certificate_authority_operations import GatewayCertificateAuthorityOperations +from ._api_gateway_config_connection_operations import ApiGatewayConfigConnectionOperations from ._group_operations import GroupOperations from ._group_user_operations import GroupUserOperations from ._identity_provider_operations import IdentityProviderOperations @@ -63,6 +68,8 @@ from ._policy_operations import PolicyOperations from ._policy_description_operations import PolicyDescriptionOperations from ._policy_fragment_operations import PolicyFragmentOperations +from ._policy_restriction_operations import PolicyRestrictionOperations +from ._policy_restriction_validations_operations import PolicyRestrictionValidationsOperations from ._portal_config_operations import PortalConfigOperations from ._portal_revision_operations import PortalRevisionOperations from ._portal_settings_operations import PortalSettingsOperations @@ -77,6 +84,8 @@ from ._product_policy_operations import ProductPolicyOperations from ._product_wiki_operations import ProductWikiOperations from ._product_wikis_operations import ProductWikisOperations +from ._product_api_link_operations import ProductApiLinkOperations +from ._product_group_link_operations import ProductGroupLinkOperations from ._quota_by_counter_keys_operations import QuotaByCounterKeysOperations from ._quota_by_period_keys_operations import QuotaByPeriodKeysOperations from ._region_operations import RegionOperations @@ -86,6 +95,9 @@ from ._api_management_skus_operations import ApiManagementSkusOperations from ._subscription_operations import SubscriptionOperations from ._tag_resource_operations import TagResourceOperations +from ._tag_api_link_operations import TagApiLinkOperations +from ._tag_operation_link_operations import TagOperationLinkOperations +from ._tag_product_link_operations import TagProductLinkOperations from ._tenant_access_operations import TenantAccessOperations from ._tenant_access_git_operations import TenantAccessGitOperations from ._tenant_configuration_operations import TenantConfigurationOperations @@ -94,13 +106,52 @@ from ._user_subscription_operations import UserSubscriptionOperations from ._user_identities_operations import UserIdentitiesOperations from ._user_confirmation_password_operations import UserConfirmationPasswordOperations -from ._documentation_operations import DocumentationOperations +from ._workspace_backend_operations import WorkspaceBackendOperations +from ._workspace_certificate_operations import WorkspaceCertificateOperations +from ._workspace_diagnostic_operations import WorkspaceDiagnosticOperations +from ._workspace_api_diagnostic_operations import WorkspaceApiDiagnosticOperations +from ._workspace_logger_operations import WorkspaceLoggerOperations +from ._api_management_workspace_links_operations import ApiManagementWorkspaceLinksOperations +from ._api_management_workspace_link_operations import ApiManagementWorkspaceLinkOperations +from ._workspace_operations import WorkspaceOperations +from ._workspace_policy_operations import WorkspacePolicyOperations +from ._workspace_named_value_operations import WorkspaceNamedValueOperations +from ._workspace_global_schema_operations import WorkspaceGlobalSchemaOperations +from ._workspace_notification_operations import WorkspaceNotificationOperations +from ._workspace_notification_recipient_user_operations import WorkspaceNotificationRecipientUserOperations +from ._workspace_notification_recipient_email_operations import WorkspaceNotificationRecipientEmailOperations +from ._workspace_policy_fragment_operations import WorkspacePolicyFragmentOperations +from ._workspace_group_operations import WorkspaceGroupOperations +from ._workspace_group_user_operations import WorkspaceGroupUserOperations +from ._workspace_subscription_operations import WorkspaceSubscriptionOperations +from ._workspace_api_version_set_operations import WorkspaceApiVersionSetOperations +from ._workspace_api_operations import WorkspaceApiOperations +from ._workspace_api_revision_operations import WorkspaceApiRevisionOperations +from ._workspace_api_release_operations import WorkspaceApiReleaseOperations +from ._workspace_api_operation_operations import WorkspaceApiOperationOperations +from ._workspace_api_operation_policy_operations import WorkspaceApiOperationPolicyOperations +from ._workspace_api_policy_operations import WorkspaceApiPolicyOperations +from ._workspace_api_schema_operations import WorkspaceApiSchemaOperations +from ._workspace_product_operations import WorkspaceProductOperations +from ._workspace_product_api_link_operations import WorkspaceProductApiLinkOperations +from ._workspace_product_group_link_operations import WorkspaceProductGroupLinkOperations +from ._workspace_product_policy_operations import WorkspaceProductPolicyOperations +from ._workspace_tag_operations import WorkspaceTagOperations +from ._workspace_tag_api_link_operations import WorkspaceTagApiLinkOperations +from ._workspace_tag_operation_link_operations import WorkspaceTagOperationLinkOperations +from ._workspace_tag_product_link_operations import WorkspaceTagProductLinkOperations +from ._workspace_api_export_operations import WorkspaceApiExportOperations +from ._operation_status_operations import OperationStatusOperations +from ._operations_results_operations import OperationsResultsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ + "AllPoliciesOperations", + "ApiGatewayOperations", + "ApiManagementGatewaySkusOperations", "ApiOperations", "ApiRevisionOperations", "ApiReleaseOperations", @@ -122,11 +173,11 @@ "ApiWikisOperations", "ApiExportOperations", "ApiVersionSetOperations", - "AuthorizationServerOperations", "AuthorizationProviderOperations", "AuthorizationOperations", "AuthorizationLoginLinksOperations", "AuthorizationAccessPolicyOperations", + "AuthorizationServerOperations", "BackendOperations", "CacheOperations", "CertificateOperations", @@ -138,11 +189,13 @@ "ApiManagementServiceSkusOperations", "ApiManagementServiceOperations", "DiagnosticOperations", + "DocumentationOperations", "EmailTemplateOperations", "GatewayOperations", "GatewayHostnameConfigurationOperations", "GatewayApiOperations", "GatewayCertificateAuthorityOperations", + "ApiGatewayConfigConnectionOperations", "GroupOperations", "GroupUserOperations", "IdentityProviderOperations", @@ -158,6 +211,8 @@ "PolicyOperations", "PolicyDescriptionOperations", "PolicyFragmentOperations", + "PolicyRestrictionOperations", + "PolicyRestrictionValidationsOperations", "PortalConfigOperations", "PortalRevisionOperations", "PortalSettingsOperations", @@ -172,6 +227,8 @@ "ProductPolicyOperations", "ProductWikiOperations", "ProductWikisOperations", + "ProductApiLinkOperations", + "ProductGroupLinkOperations", "QuotaByCounterKeysOperations", "QuotaByPeriodKeysOperations", "RegionOperations", @@ -181,6 +238,9 @@ "ApiManagementSkusOperations", "SubscriptionOperations", "TagResourceOperations", + "TagApiLinkOperations", + "TagOperationLinkOperations", + "TagProductLinkOperations", "TenantAccessOperations", "TenantAccessGitOperations", "TenantConfigurationOperations", @@ -189,7 +249,43 @@ "UserSubscriptionOperations", "UserIdentitiesOperations", "UserConfirmationPasswordOperations", - "DocumentationOperations", + "WorkspaceBackendOperations", + "WorkspaceCertificateOperations", + "WorkspaceDiagnosticOperations", + "WorkspaceApiDiagnosticOperations", + "WorkspaceLoggerOperations", + "ApiManagementWorkspaceLinksOperations", + "ApiManagementWorkspaceLinkOperations", + "WorkspaceOperations", + "WorkspacePolicyOperations", + "WorkspaceNamedValueOperations", + "WorkspaceGlobalSchemaOperations", + "WorkspaceNotificationOperations", + "WorkspaceNotificationRecipientUserOperations", + "WorkspaceNotificationRecipientEmailOperations", + "WorkspacePolicyFragmentOperations", + "WorkspaceGroupOperations", + "WorkspaceGroupUserOperations", + "WorkspaceSubscriptionOperations", + "WorkspaceApiVersionSetOperations", + "WorkspaceApiOperations", + "WorkspaceApiRevisionOperations", + "WorkspaceApiReleaseOperations", + "WorkspaceApiOperationOperations", + "WorkspaceApiOperationPolicyOperations", + "WorkspaceApiPolicyOperations", + "WorkspaceApiSchemaOperations", + "WorkspaceProductOperations", + "WorkspaceProductApiLinkOperations", + "WorkspaceProductGroupLinkOperations", + "WorkspaceProductPolicyOperations", + "WorkspaceTagOperations", + "WorkspaceTagApiLinkOperations", + "WorkspaceTagOperationLinkOperations", + "WorkspaceTagProductLinkOperations", + "WorkspaceApiExportOperations", + "OperationStatusOperations", + "OperationsResultsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_all_policies_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_all_policies_operations.py new file mode 100644 index 000000000000..0d615bffd794 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_all_policies_operations.py @@ -0,0 +1,183 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/allPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AllPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`all_policies` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.AllPoliciesContract"]: + """Status of all policies of API Management services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An iterator like instance of either AllPoliciesContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AllPoliciesContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AllPoliciesCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AllPoliciesCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py index ecbaf566bebc..edd4ab63e017 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -98,7 +101,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -122,7 +125,7 @@ def build_get_entity_tag_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -142,7 +145,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,7 +169,7 @@ def build_get_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -193,7 +196,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -218,7 +221,7 @@ def build_create_or_update_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -249,7 +252,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -274,7 +277,7 @@ def build_update_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -304,7 +307,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -328,7 +331,7 @@ def build_delete_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -402,7 +405,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DiagnosticCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -425,7 +428,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -441,7 +443,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -492,7 +493,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -516,7 +517,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -559,7 +559,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,7 +583,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -601,7 +600,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -720,7 +719,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -757,7 +756,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -773,15 +771,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("DiagnosticContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -900,7 +892,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -937,7 +929,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -955,7 +946,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -986,7 +977,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1011,7 +1002,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py index 16262ba68e82..43fbac44301c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +71,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -125,8 +128,8 @@ def get( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. :type api_id: str :param format: Format in which to export the Api Details to the Storage Blob with Sas Key valid - for 5 minutes. Known values are: "swagger-link", "wsdl-link", "wadl-link", "openapi-link", and - "openapi+json-link". Required. + for 5 minutes. New formats can be added in the future. Known values are: "swagger-link", + "wsdl-link", "wadl-link", "openapi-link", and "openapi+json-link". Required. :type format: str or ~azure.mgmt.apimanagement.models.ExportFormat :param export: Query parameter required to export the API details. "true" Required. :type export: str or ~azure.mgmt.apimanagement.models.ExportApi @@ -134,7 +137,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -159,7 +162,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -174,7 +176,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiExportResult", pipeline_response) + deserialized = self._deserialize("ApiExportResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_config_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_config_connection_operations.py new file mode 100644 index 000000000000..cc28f6f60ae2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_config_connection_operations.py @@ -0,0 +1,750 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_gateway_request( + resource_group_name: str, gateway_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, gateway_name: str, config_connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "configConnectionName": _SERIALIZER.url( + "config_connection_name", + config_connection_name, + "str", + max_length=30, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, gateway_name: str, config_connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "configConnectionName": _SERIALIZER.url( + "config_connection_name", + config_connection_name, + "str", + max_length=30, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "configConnectionName": _SERIALIZER.url( + "config_connection_name", + config_connection_name, + "str", + max_length=30, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiGatewayConfigConnectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_gateway_config_connection` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_gateway( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.ApiManagementGatewayConfigConnectionResource"]: + """List all API Management gateway config connections within a gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :return: An iterator like instance of either ApiManagementGatewayConfigConnectionResource or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayConfigConnectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_gateway_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayConfigConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, gateway_name: str, config_connection_name: str, **kwargs: Any + ) -> _models.ApiManagementGatewayConfigConnectionResource: + """Gets an API Management gateway config connection resource description. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :return: ApiManagementGatewayConfigConnectionResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayConfigConnectionResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "ApiManagementGatewayConfigConnectionResource", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + parameters: Union[_models.ApiManagementGatewayConfigConnectionResource, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementGatewayConfigConnectionResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + parameters: _models.ApiManagementGatewayConfigConnectionResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayConfigConnectionResource]: + """Creates or updates an API Management gateway config connection. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway config + connection operation. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either + ApiManagementGatewayConfigConnectionResource or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayConfigConnectionResource]: + """Creates or updates an API Management gateway config connection. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway config + connection operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either + ApiManagementGatewayConfigConnectionResource or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + parameters: Union[_models.ApiManagementGatewayConfigConnectionResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayConfigConnectionResource]: + """Creates or updates an API Management gateway config connection. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway config + connection operation. Is either a ApiManagementGatewayConfigConnectionResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + or IO[bytes] + :return: An instance of LROPoller that returns either + ApiManagementGatewayConfigConnectionResource or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiManagementGatewayConfigConnectionResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize( + "ApiManagementGatewayConfigConnectionResource", pipeline_response.http_response + ) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementGatewayConfigConnectionResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementGatewayConfigConnectionResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, gateway_name: str, config_connection_name: str, if_match: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, gateway_name: str, config_connection_name: str, if_match: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing API Management gateway config connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param config_connection_name: The name of the API Management gateway config connection. + Required. + :type config_connection_name: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + if_match=if_match, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_operations.py new file mode 100644 index 000000000000..9007c6e12944 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_operations.py @@ -0,0 +1,1020 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, gateway_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, gateway_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, gateway_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, gateway_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/gateways") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiGatewayOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_gateway` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_or_update_initial( + self, + resource_group_name: str, + gateway_name: str, + parameters: Union[_models.ApiManagementGatewayResource, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementGatewayResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: _models.ApiManagementGatewayResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayResource]: + """Creates or updates an API Management gateway. This is long running operation and could take + several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayResource]: + """Creates or updates an API Management gateway. This is long running operation and could take + several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: Union[_models.ApiManagementGatewayResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayResource]: + """Creates or updates an API Management gateway. This is long running operation and could take + several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Is either a ApiManagementGatewayResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource or IO[bytes] + :return: An instance of LROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementGatewayResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementGatewayResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + gateway_name: str, + parameters: Union[_models.ApiManagementGatewayUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiManagementGatewayUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: _models.ApiManagementGatewayUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayResource]: + """Updates an existing API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayResource]: + """Updates an existing API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + gateway_name: str, + parameters: Union[_models.ApiManagementGatewayUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayResource]: + """Updates an existing API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway operation. + Is either a ApiManagementGatewayUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateParameters or + IO[bytes] + :return: An instance of LROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementGatewayResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementGatewayResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get(self, resource_group_name: str, gateway_name: str, **kwargs: Any) -> _models.ApiManagementGatewayResource: + """Gets an API Management gateway resource description. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :return: ApiManagementGatewayResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiManagementGatewayResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial(self, resource_group_name: str, gateway_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> LROPoller[_models.ApiManagementGatewayResource]: + """Deletes an existing API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :return: An instance of LROPoller that returns either ApiManagementGatewayResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = self._deserialize("ApiManagementGatewayResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementGatewayResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementGatewayResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ApiManagementGatewayResource"]: + """List all API Management gateways within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ApiManagementGatewayResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.ApiManagementGatewayResource"]: + """List all API Management gateways within a subscription. + + :return: An iterator like instance of either ApiManagementGatewayResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementGatewayListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiManagementGatewayListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py index 97bef2e9b2a2..9d8b743b6710 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +79,7 @@ def build_list_by_service_request( "issueId": _SERIALIZER.url( "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -108,7 +111,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +138,7 @@ def build_get_entity_tag_request( "attachmentId": _SERIALIZER.url( "attachment_id", attachment_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -161,7 +164,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +191,7 @@ def build_get_request( "attachmentId": _SERIALIZER.url( "attachment_id", attachment_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -216,7 +219,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -244,7 +247,7 @@ def build_create_or_update_request( "attachmentId": _SERIALIZER.url( "attachment_id", attachment_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -276,7 +279,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -303,7 +306,7 @@ def build_delete_request( "attachmentId": _SERIALIZER.url( "attachment_id", attachment_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -383,7 +386,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IssueAttachmentCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +410,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -423,7 +425,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -478,7 +479,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -503,7 +504,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -549,7 +549,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,7 +574,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -592,7 +591,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -723,7 +722,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -761,7 +760,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -777,15 +775,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueAttachmentContract", pipeline_response) + deserialized = self._deserialize("IssueAttachmentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -826,7 +818,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -852,7 +844,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py index b51496e88e4e..202a965e837f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +79,7 @@ def build_list_by_service_request( "issueId": _SERIALIZER.url( "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -108,7 +111,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +138,7 @@ def build_get_entity_tag_request( "commentId": _SERIALIZER.url( "comment_id", comment_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -161,7 +164,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +191,7 @@ def build_get_request( "commentId": _SERIALIZER.url( "comment_id", comment_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -216,7 +219,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -244,7 +247,7 @@ def build_create_or_update_request( "commentId": _SERIALIZER.url( "comment_id", comment_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -276,7 +279,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -303,7 +306,7 @@ def build_delete_request( "commentId": _SERIALIZER.url( "comment_id", comment_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -383,7 +386,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IssueCommentCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,7 +410,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -423,7 +425,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -478,7 +479,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -503,7 +504,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -549,7 +549,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -574,7 +574,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -592,7 +591,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueCommentContract", pipeline_response) + deserialized = self._deserialize("IssueCommentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -723,7 +722,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -761,7 +760,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -777,15 +775,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IssueCommentContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueCommentContract", pipeline_response) + deserialized = self._deserialize("IssueCommentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -826,7 +818,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -852,7 +844,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py index 6a82c1c76e79..9a94444a6dea 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +76,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -103,7 +106,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +130,7 @@ def build_get_entity_tag_request( "issueId": _SERIALIZER.url( "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -154,7 +157,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +181,7 @@ def build_get_request( "issueId": _SERIALIZER.url( "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -209,7 +212,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -234,7 +237,7 @@ def build_create_or_update_request( "issueId": _SERIALIZER.url( "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -265,7 +268,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -290,7 +293,7 @@ def build_update_request( "issueId": _SERIALIZER.url( "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -320,7 +323,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -344,7 +347,7 @@ def build_delete_request( "issueId": _SERIALIZER.url( "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -422,7 +425,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IssueCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -446,7 +449,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -462,7 +464,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -513,7 +514,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -537,7 +538,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -588,7 +588,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -613,7 +613,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -631,7 +630,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueContract", pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -750,7 +749,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -787,7 +786,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -803,15 +801,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IssueContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueContract", pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -930,7 +922,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -967,7 +959,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -985,7 +976,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueContract", pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1016,7 +1007,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1041,7 +1032,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py index d81a58ffebf8..6c8c8cf94b51 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,8 +30,12 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +from .._vendor import ApiManagementClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +49,7 @@ def build_perform_connectivity_check_async_request( # pylint: disable=name-too- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -64,7 +70,7 @@ def build_perform_connectivity_check_async_request( # pylint: disable=name-too- min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -81,14 +87,15 @@ def build_perform_connectivity_check_async_request( # pylint: disable=name-too- class ApiManagementClientOperationsMixin(ApiManagementClientMixinABC): + def _perform_connectivity_check_async_initial( # pylint: disable=name-too-long self, resource_group_name: str, service_name: str, connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ConnectivityCheckResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,7 +108,7 @@ def _perform_connectivity_check_async_initial( # pylint: disable=name-too-long api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ConnectivityCheckResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -122,10 +129,10 @@ def _perform_connectivity_check_async_initial( # pylint: disable=name-too-long headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -133,16 +140,22 @@ def _perform_connectivity_check_async_initial( # pylint: disable=name-too-long response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -254,10 +267,11 @@ def begin_perform_connectivity_check_async( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response) + deserialized = self._deserialize("ConnectivityCheckResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_gateway_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_gateway_skus_operations.py new file mode 100644 index 000000000000..52f49047f855 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_gateway_skus_operations.py @@ -0,0 +1,186 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_available_skus_request( + resource_group_name: str, gateway_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/skus", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "gatewayName": _SERIALIZER.url( + "gateway_name", + gateway_name, + "str", + max_length=45, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiManagementGatewaySkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_gateway_skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_available_skus( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> Iterable["_models.GatewayResourceSkuResult"]: + """Gets available SKUs for API Management gateway. + + Gets all available SKU for a given API Management gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param gateway_name: The name of the API Management gateway. Required. + :type gateway_name: str + :return: An iterator like instance of either GatewayResourceSkuResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayResourceSkuResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GatewayResourceSkuResults] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_available_skus_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GatewayResourceSkuResults", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py index 919ae35e4639..108cea8c79e8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,7 +107,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -120,7 +122,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py index 6aefc4c75dbe..58ac0572fec2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_restore_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -66,7 +71,7 @@ def build_restore_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -88,7 +93,7 @@ def build_backup_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -109,7 +114,7 @@ def build_backup_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -131,7 +136,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -152,7 +157,7 @@ def build_create_or_update_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -174,7 +179,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -195,7 +200,7 @@ def build_update_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -215,7 +220,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -235,7 +240,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -255,7 +260,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -275,7 +280,7 @@ def build_delete_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -295,7 +300,8 @@ def build_migrate_to_stv2_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -315,7 +321,7 @@ def build_migrate_to_stv2_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -324,6 +330,8 @@ def build_migrate_to_stv2_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) @@ -333,7 +341,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -345,7 +353,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -363,13 +371,13 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -389,7 +397,7 @@ def build_get_sso_token_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -409,7 +417,7 @@ def build_get_sso_token_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -427,7 +435,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -436,7 +444,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability" ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -458,7 +466,7 @@ def build_get_domain_ownership_identifier_request( # pylint: disable=name-too-l _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -466,7 +474,7 @@ def build_get_domain_ownership_identifier_request( # pylint: disable=name-too-l "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier" ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -486,7 +494,7 @@ def build_apply_network_configuration_updates_request( # pylint: disable=name-t _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -507,7 +515,7 @@ def build_apply_network_configuration_updates_request( # pylint: disable=name-t min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -548,8 +556,8 @@ def _restore_initial( service_name: str, parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -562,7 +570,7 @@ def _restore_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -583,10 +591,10 @@ def _restore_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -594,18 +602,20 @@ def _restore_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -724,10 +734,11 @@ def begin_restore( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -757,8 +768,8 @@ def _backup_initial( service_name: str, parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -771,7 +782,7 @@ def _backup_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -792,10 +803,10 @@ def _backup_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -803,17 +814,19 @@ def _backup_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -927,10 +940,11 @@ def begin_backup( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -960,8 +974,8 @@ def _create_or_update_initial( service_name: str, parameters: Union[_models.ApiManagementServiceResource, IO[bytes]], **kwargs: Any - ) -> _models.ApiManagementServiceResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -974,7 +988,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ApiManagementServiceResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -995,10 +1009,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1006,15 +1020,15 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1129,10 +1143,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1160,8 +1175,8 @@ def _update_initial( service_name: str, parameters: Union[_models.ApiManagementServiceUpdateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1174,7 +1189,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1195,10 +1210,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1206,16 +1221,22 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1325,10 +1346,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1363,7 +1385,7 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1385,7 +1407,6 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1400,17 +1421,15 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _delete_initial( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + def _delete_initial(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1422,7 +1441,7 @@ def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -1432,10 +1451,10 @@ def _delete_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1443,16 +1462,22 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None + response_headers = {} if response.status_code == 202: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1491,12 +1516,17 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -1517,9 +1547,13 @@ def get_long_running_output(pipeline_response): ) def _migrate_to_stv2_initial( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + self, + resource_group_name: str, + service_name: str, + parameters: Optional[Union[_models.MigrateToStv2Contract, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1527,24 +1561,39 @@ def _migrate_to_stv2_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "MigrateToStv2Contract") + else: + _json = None _request = build_migrate_to_stv2_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, api_version=api_version, + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1552,26 +1601,94 @@ def _migrate_to_stv2_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def begin_migrate_to_stv2( + self, + resource_group_name: str, + service_name: str, + parameters: Optional[_models.MigrateToStv2Contract] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Upgrades an API Management service to the Stv2 platform. For details refer to + https://aka.ms/apim-migrate-stv2. This change is not reversible. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param parameters: Optional parameters supplied to migrate service. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.MigrateToStv2Contract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ApiManagementServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_migrate_to_stv2( + self, + resource_group_name: str, + service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Upgrades an API Management service to the Stv2 platform. For details refer to + https://aka.ms/apim-migrate-stv2. This change is not reversible. This is long running operation + and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param parameters: Optional parameters supplied to migrate service. Default value is None. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ApiManagementServiceResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace def begin_migrate_to_stv2( - self, resource_group_name: str, service_name: str, **kwargs: Any + self, + resource_group_name: str, + service_name: str, + parameters: Optional[Union[_models.MigrateToStv2Contract, IO[bytes]]] = None, + **kwargs: Any ) -> LROPoller[_models.ApiManagementServiceResource]: """Upgrades an API Management service to the Stv2 platform. For details refer to https://aka.ms/apim-migrate-stv2. This change is not reversible. This is long running operation @@ -1582,16 +1699,20 @@ def begin_migrate_to_stv2( :type resource_group_name: str :param service_name: The name of the API Management service. Required. :type service_name: str + :param parameters: Optional parameters supplied to migrate service. Is either a + MigrateToStv2Contract type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.MigrateToStv2Contract or IO[bytes] :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ApiManagementServiceResource] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1600,16 +1721,19 @@ def begin_migrate_to_stv2( raw_result = self._migrate_to_stv2_initial( resource_group_name=resource_group_name, service_name=service_name, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1654,7 +1778,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiManagementServiceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1672,7 +1796,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1688,7 +1811,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1734,7 +1856,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApiManagementServiceResource" api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiManagementServiceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1751,7 +1873,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1767,7 +1888,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1812,7 +1932,7 @@ def get_sso_token( :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1834,7 +1954,6 @@ def get_sso_token( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1849,7 +1968,7 @@ def get_sso_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiManagementServiceGetSsoTokenResult", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceGetSsoTokenResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1908,7 +2027,7 @@ def check_name_availability( :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1940,7 +2059,6 @@ def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1955,7 +2073,7 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiManagementServiceNameAvailabilityResult", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceNameAvailabilityResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1972,7 +2090,7 @@ def get_domain_ownership_identifier( :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1992,7 +2110,6 @@ def get_domain_ownership_identifier( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2007,7 +2124,9 @@ def get_domain_ownership_identifier( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApiManagementServiceGetDomainOwnershipIdentifierResult", pipeline_response) + deserialized = self._deserialize( + "ApiManagementServiceGetDomainOwnershipIdentifierResult", pipeline_response.http_response + ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2020,8 +2139,8 @@ def _apply_network_configuration_updates_initial( # pylint: disable=name-too-lo service_name: str, parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO[bytes]]] = None, **kwargs: Any - ) -> Optional[_models.ApiManagementServiceResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2034,7 +2153,7 @@ def _apply_network_configuration_updates_initial( # pylint: disable=name-too-lo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2058,10 +2177,10 @@ def _apply_network_configuration_updates_initial( # pylint: disable=name-too-lo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2069,18 +2188,20 @@ def _apply_network_configuration_updates_initial( # pylint: disable=name-too-lo response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2202,10 +2323,11 @@ def begin_apply_network_configuration_updates( # pylint: disable=name-too-long params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response) + deserialized = self._deserialize("ApiManagementServiceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py index 7f078f145606..eb35f9740cfa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +45,7 @@ def build_list_available_service_skus_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +65,7 @@ def build_list_available_service_skus_request( # pylint: disable=name-too-long min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -118,7 +121,7 @@ def list_available_service_skus( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceSkuResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,7 +140,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -153,7 +155,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py index 7135f407127f..086e30ce68b6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +43,13 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -93,7 +96,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ApiManagementSku"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiManagementSkusResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,7 +113,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -126,7 +128,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_link_operations.py new file mode 100644 index 000000000000..8ecf3d5eeaf9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_link_operations.py @@ -0,0 +1,162 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaceLinks/{workspaceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiManagementWorkspaceLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_workspace_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> _models.ApiManagementWorkspaceLinksResource: + """Gets an API Management WorkspaceLink resource description. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :return: ApiManagementWorkspaceLinksResource or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementWorkspaceLinksResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiManagementWorkspaceLinksResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_links_operations.py new file mode 100644 index 000000000000..64d737d47ff6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_links_operations.py @@ -0,0 +1,185 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaceLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ApiManagementWorkspaceLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_workspace_links` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ApiManagementWorkspaceLinksResource"]: + """List all API Management workspaceLinks for a service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An iterator like instance of either ApiManagementWorkspaceLinksResource or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiManagementWorkspaceLinksListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiManagementWorkspaceLinksListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py index 5e83bbee5da7..c0adc75137d7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_by_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +76,7 @@ def build_list_by_api_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -101,7 +104,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,7 +126,7 @@ def build_get_entity_tag_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -143,7 +146,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -165,7 +168,7 @@ def build_get_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -192,7 +195,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -215,7 +218,7 @@ def build_create_or_update_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -246,7 +249,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -269,7 +272,7 @@ def build_update_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -299,7 +302,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -321,7 +324,7 @@ def build_delete_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -402,7 +405,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,7 +429,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -442,7 +444,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -493,7 +494,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -517,7 +518,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -560,7 +560,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -584,7 +584,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -602,7 +601,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OperationContract", pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -721,7 +720,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,7 +757,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -774,15 +772,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("OperationContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OperationContract", pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -901,7 +893,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -938,7 +930,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -956,7 +947,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OperationContract", pipeline_response) + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -987,7 +978,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1012,7 +1003,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py index 44a0df196c4a..a35871d9eeab 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_list_by_operation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +66,7 @@ def build_list_by_operation_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -89,7 +92,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +115,7 @@ def build_get_entity_tag_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -140,7 +143,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +166,7 @@ def build_get_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -193,7 +196,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -217,7 +220,7 @@ def build_create_or_update_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -249,7 +252,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,7 +275,7 @@ def build_delete_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -327,7 +330,7 @@ def list_by_operation( :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -351,7 +354,6 @@ def list_by_operation( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -366,7 +368,7 @@ def list_by_operation( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyCollection", pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -402,7 +404,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -427,7 +429,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -482,7 +483,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,7 +509,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -526,7 +526,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -654,7 +654,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -692,7 +692,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -708,15 +707,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -756,7 +749,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -782,7 +775,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py index 476aa94e9030..be9d0d2e7f19 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +59,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +79,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -104,7 +109,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +130,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -145,7 +150,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,7 +171,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -192,7 +197,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -214,7 +219,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -238,7 +243,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -260,7 +265,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -290,7 +295,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -311,7 +316,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -342,7 +347,7 @@ def build_list_by_tags_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -362,7 +367,7 @@ def build_list_by_tags_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -453,7 +458,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,7 +482,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -493,7 +497,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -539,7 +542,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, api_id: st :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -562,7 +565,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, api_id: st headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -600,7 +602,7 @@ def get(self, resource_group_name: str, service_name: str, api_id: str, **kwargs :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -623,7 +625,6 @@ def get(self, resource_group_name: str, service_name: str, api_id: str, **kwargs headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -641,7 +642,7 @@ def get(self, resource_group_name: str, service_name: str, api_id: str, **kwargs response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -656,8 +657,8 @@ def _create_or_update_initial( parameters: Union[_models.ApiCreateOrUpdateParameter, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.ApiContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -670,7 +671,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ApiContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -693,32 +694,33 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -851,14 +853,19 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -982,7 +989,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1018,7 +1025,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1036,15 +1042,14 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, service_name: str, @@ -1052,27 +1057,8 @@ def delete( # pylint: disable=inconsistent-return-statements if_match: str, delete_revisions: Optional[bool] = None, **kwargs: Any - ) -> None: - """Deletes the specified API of the API Management service instance. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param api_id: API revision identifier. Must be unique in the current API Management service - instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. - :type api_id: str - :param if_match: ETag of the Entity. ETag should match the current entity state from the header - response of the GET request or it should be * for unconditional update. Required. - :type if_match: str - :param delete_revisions: Delete all revisions of the Api. Default value is None. - :type delete_revisions: bool - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1084,7 +1070,7 @@ def delete( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -1097,23 +1083,112 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + if_match: str, + delete_revisions: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified API of the API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param delete_revisions: Delete all revisions of the Api. Default value is None. + :type delete_revisions: bool + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + if_match=if_match, + delete_revisions=delete_revisions, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_by_tags( @@ -1160,7 +1235,7 @@ def list_by_tags( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagResourceCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1183,7 +1258,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1199,7 +1273,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py index 79942f86e7a9..3a6c22164ebb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_list_by_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +65,7 @@ def build_list_by_api_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -87,7 +90,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +112,7 @@ def build_get_entity_tag_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -136,7 +139,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop( "Accept", "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml", @@ -161,7 +164,7 @@ def build_get_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -190,7 +193,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -213,7 +216,7 @@ def build_create_or_update_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -244,7 +247,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -266,7 +269,7 @@ def build_delete_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -318,7 +321,7 @@ def list_by_api( :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,7 +344,6 @@ def list_by_api( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -356,7 +358,7 @@ def list_by_api( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyCollection", pipeline_response) + deserialized = self._deserialize("PolicyCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -388,7 +390,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -412,7 +414,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -463,7 +464,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,7 +489,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -504,15 +504,9 @@ def get( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -628,7 +622,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -665,7 +659,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -681,15 +674,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -725,7 +712,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -750,7 +737,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py index ce925bce9e22..2501bfe880ac 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_apis_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_by_apis_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -150,7 +153,7 @@ def list_by_apis( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProductCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,7 +176,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -189,7 +191,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py index 26da086fdbee..16591e6cca7a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -98,7 +101,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -122,7 +125,7 @@ def build_get_entity_tag_request( "releaseId": _SERIALIZER.url( "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -142,7 +145,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,7 +169,7 @@ def build_get_request( "releaseId": _SERIALIZER.url( "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -193,7 +196,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -218,7 +221,7 @@ def build_create_or_update_request( "releaseId": _SERIALIZER.url( "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -249,7 +252,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -274,7 +277,7 @@ def build_update_request( "releaseId": _SERIALIZER.url( "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -304,7 +307,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -328,7 +331,7 @@ def build_delete_request( "releaseId": _SERIALIZER.url( "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -404,7 +407,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiReleaseCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -427,7 +430,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -443,7 +445,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -494,7 +495,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -518,7 +519,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -561,7 +561,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,7 +585,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -603,7 +602,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiReleaseContract", pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -722,7 +721,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -759,7 +758,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -775,15 +773,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiReleaseContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiReleaseContract", pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -902,7 +894,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -939,7 +931,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -957,7 +948,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiReleaseContract", pipeline_response) + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -988,7 +979,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1013,7 +1004,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py index fdd05e6576ab..5f47d8e09530 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -150,7 +153,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiRevisionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,7 +176,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -189,7 +191,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py index ddef9209f792..ec13d6a1af21 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +58,7 @@ def build_list_by_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +79,7 @@ def build_list_by_api_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -100,7 +105,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -122,7 +127,7 @@ def build_get_entity_tag_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -142,7 +147,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +169,7 @@ def build_get_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -191,7 +196,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -214,7 +219,7 @@ def build_create_or_update_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -246,7 +251,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -268,7 +273,7 @@ def build_delete_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -344,7 +349,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SchemaCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,7 +372,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -383,7 +387,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -434,7 +437,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +461,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -501,7 +503,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.SchemaContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,7 +527,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -543,7 +544,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SchemaContract", pipeline_response) + deserialized = self._deserialize("SchemaContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -559,8 +560,8 @@ def _create_or_update_initial( parameters: Union[_models.SchemaContract, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.SchemaContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -573,7 +574,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SchemaContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -597,32 +598,33 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("SchemaContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("SchemaContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -768,14 +770,19 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("SchemaContract", pipeline_response) + deserialized = self._deserialize("SchemaContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -833,7 +840,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -859,7 +866,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py index 4bc90e1d8cbb..e8c086cc4922 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -103,7 +106,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +130,7 @@ def build_get_entity_tag_request( "tagDescriptionId": _SERIALIZER.url( "tag_description_id", tag_description_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -152,7 +155,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -176,7 +179,7 @@ def build_get_request( "tagDescriptionId": _SERIALIZER.url( "tag_description_id", tag_description_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -203,7 +206,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -228,7 +231,7 @@ def build_create_or_update_request( "tagDescriptionId": _SERIALIZER.url( "tag_description_id", tag_description_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -259,7 +262,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -283,7 +286,7 @@ def build_delete_request( "tagDescriptionId": _SERIALIZER.url( "tag_description_id", tag_description_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -360,7 +363,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagDescriptionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -383,7 +386,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -399,7 +401,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -450,7 +451,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,7 +475,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -517,7 +517,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,7 +541,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -559,7 +558,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagDescriptionContract", pipeline_response) + deserialized = self._deserialize("TagDescriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -678,7 +677,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,7 +714,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -731,15 +729,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("TagDescriptionContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagDescriptionContract", pipeline_response) + deserialized = self._deserialize("TagDescriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -776,7 +768,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -801,7 +793,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py index 670236e3bc86..4bd095229c15 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +122,7 @@ def build_get_entity_tag_request( "versionSetId": _SERIALIZER.url( "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -139,7 +142,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +165,7 @@ def build_get_request( "versionSetId": _SERIALIZER.url( "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -188,7 +191,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -212,7 +215,7 @@ def build_create_or_update_request( "versionSetId": _SERIALIZER.url( "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -242,7 +245,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -266,7 +269,7 @@ def build_update_request( "versionSetId": _SERIALIZER.url( "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -295,7 +298,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -318,7 +321,7 @@ def build_delete_request( "versionSetId": _SERIALIZER.url( "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -388,7 +391,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiVersionSetCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,7 +413,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -426,7 +428,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -472,7 +473,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, version_se :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -495,7 +496,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, version_se headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -535,7 +535,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -558,7 +558,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -576,7 +575,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -683,7 +682,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -719,7 +718,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -735,15 +733,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -850,7 +842,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,7 +878,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -904,7 +895,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ApiVersionSetContract", pipeline_response) + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -932,7 +923,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -956,7 +947,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wiki_operations.py index e0564c75b516..ac46c1025e0c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wiki_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wiki_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +65,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -82,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +106,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -129,7 +132,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -151,7 +154,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -175,7 +178,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -197,7 +200,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -220,7 +223,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -241,7 +244,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -291,7 +294,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, api_id: st :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -314,7 +317,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, api_id: st headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -352,7 +354,7 @@ def get(self, resource_group_name: str, service_name: str, api_id: str, **kwargs :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +377,6 @@ def get(self, resource_group_name: str, service_name: str, api_id: str, **kwargs headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -393,7 +394,7 @@ def get(self, resource_group_name: str, service_name: str, api_id: str, **kwargs response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -500,7 +501,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -536,7 +537,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -552,15 +552,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("WikiContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -667,7 +661,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -703,7 +697,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -721,7 +714,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -749,7 +742,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -773,7 +766,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wikis_operations.py index 952e477d27d2..0022fc69d93b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wikis_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wikis_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -149,7 +152,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WikiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,7 +175,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -188,7 +190,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py index 95cf64cd362c..b269698af935 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_by_authorization_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +86,7 @@ def build_list_by_authorization_request( "authorizationId": _SERIALIZER.url( "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -115,7 +118,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +157,7 @@ def build_get_request( min_length=1, pattern=r"^[^*#&+:<>?]+$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -182,7 +185,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -222,7 +225,7 @@ def build_create_or_update_request( min_length=1, pattern=r"^[^*#&+:<>?]+$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -254,7 +257,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -293,7 +296,7 @@ def build_delete_request( min_length=1, pattern=r"^[^*#&+:<>?]+$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -372,7 +375,7 @@ def list_by_authorization( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AuthorizationAccessPolicyCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -396,7 +399,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -412,7 +414,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -469,7 +470,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -494,7 +495,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -512,7 +512,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response) + deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -635,7 +635,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -673,7 +673,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -689,15 +688,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response) + deserialized = self._deserialize("AuthorizationAccessPolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -735,7 +728,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -761,7 +754,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py index 8458e416f305..8d09ac4919f9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +49,7 @@ def build_post_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -78,7 +81,7 @@ def build_post_request( "authorizationId": _SERIALIZER.url( "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -208,7 +211,7 @@ def post( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,7 +247,6 @@ def post( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -262,7 +264,7 @@ def post( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationLoginResponseContract", pipeline_response) + deserialized = self._deserialize("AuthorizationLoginResponseContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py index c6dee0f2b56d..0df005458f18 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_authorization_provider_request( # pylint: disable=name-too-lo _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +82,7 @@ def build_list_by_authorization_provider_request( # pylint: disable=name-too-lo min_length=1, pattern=r"^[^*#&+:<>?]+$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -110,7 +113,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -141,7 +144,7 @@ def build_get_request( "authorizationId": _SERIALIZER.url( "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -168,7 +171,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -200,7 +203,7 @@ def build_create_or_update_request( "authorizationId": _SERIALIZER.url( "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -231,7 +234,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -262,7 +265,7 @@ def build_delete_request( "authorizationId": _SERIALIZER.url( "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -288,7 +291,7 @@ def build_confirm_consent_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -320,7 +323,7 @@ def build_confirm_consent_code_request( "authorizationId": _SERIALIZER.url( "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -396,7 +399,7 @@ def list_by_authorization_provider( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AuthorizationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,7 +422,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -435,7 +437,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -489,7 +490,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -513,7 +514,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -531,7 +531,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationContract", pipeline_response) + deserialized = self._deserialize("AuthorizationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -644,7 +644,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -681,7 +681,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -697,15 +696,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationContract", pipeline_response) + deserialized = self._deserialize("AuthorizationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -740,7 +733,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -765,7 +758,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -879,7 +871,7 @@ def confirm_consent_code( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,7 +907,6 @@ def confirm_consent_code( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_provider_operations.py index 6d2cb523a323..b6bcf514520a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_provider_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +127,7 @@ def build_get_request( min_length=1, pattern=r"^[^*#&+:<>?]+$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -150,7 +153,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -179,7 +182,7 @@ def build_create_or_update_request( min_length=1, pattern=r"^[^*#&+:<>?]+$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -209,7 +212,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,7 +240,7 @@ def build_delete_request( min_length=1, pattern=r"^[^*#&+:<>?]+$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -310,7 +313,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AuthorizationProviderCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,7 +335,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -348,7 +350,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -395,7 +396,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,7 +419,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -436,7 +436,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response) + deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -540,7 +540,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -576,7 +576,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -592,15 +591,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response) + deserialized = self._deserialize("AuthorizationProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -627,7 +620,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -651,7 +644,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py index 540201ef5749..522e7e30f2ad 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +120,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +161,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +187,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -206,7 +209,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -230,7 +233,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -252,7 +255,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -275,7 +278,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +299,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -317,7 +320,7 @@ def build_list_secrets_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -338,7 +341,7 @@ def build_list_secrets_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "authsid": _SERIALIZER.url("authsid", authsid, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -410,7 +413,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AuthorizationServerCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,7 +435,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -448,7 +450,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -493,7 +494,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, authsid: s :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -516,7 +517,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, authsid: s headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -555,7 +555,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -578,7 +578,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -596,7 +595,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -700,7 +699,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -736,7 +735,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -752,15 +750,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -865,7 +857,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -901,7 +893,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -919,7 +910,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationServerContract", pipeline_response) + deserialized = self._deserialize("AuthorizationServerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -946,7 +937,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -970,7 +961,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1005,7 +995,7 @@ def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1028,7 +1018,6 @@ def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1046,7 +1035,7 @@ def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AuthorizationServerSecretsContract", pipeline_response) + deserialized = self._deserialize("AuthorizationServerSecretsContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py index 077c1a99daad..84e60d51177e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +120,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +161,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +187,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -206,7 +209,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -230,7 +233,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -252,7 +255,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -275,7 +278,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +299,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -317,7 +320,7 @@ def build_reconnect_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -339,7 +342,7 @@ def build_reconnect_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -412,7 +415,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackendCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,7 +437,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -450,7 +452,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -496,7 +497,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, backend_id :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -519,7 +520,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, backend_id headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -559,7 +559,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,7 +582,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -600,7 +599,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("BackendContract", pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -707,7 +706,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -743,7 +742,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -759,15 +757,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("BackendContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("BackendContract", pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -874,7 +866,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -910,7 +902,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -928,7 +919,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("BackendContract", pipeline_response) + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -956,7 +947,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -980,7 +971,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1089,7 +1079,7 @@ def reconnect( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1127,7 +1117,6 @@ def reconnect( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py index 9fb0b089c747..039c01948f92 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +72,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -93,7 +96,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +117,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "cacheId": _SERIALIZER.url("cache_id", cache_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -134,7 +137,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +158,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "cacheId": _SERIALIZER.url("cache_id", cache_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -181,7 +184,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +206,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "cacheId": _SERIALIZER.url("cache_id", cache_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -227,7 +230,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -249,7 +252,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "cacheId": _SERIALIZER.url("cache_id", cache_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -272,7 +275,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -293,7 +296,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "cacheId": _SERIALIZER.url("cache_id", cache_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -357,7 +360,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CacheCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -378,7 +381,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -394,7 +396,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -440,7 +441,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, cache_id: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,7 +464,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, cache_id: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -501,7 +501,7 @@ def get(self, resource_group_name: str, service_name: str, cache_id: str, **kwar :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,7 +524,6 @@ def get(self, resource_group_name: str, service_name: str, cache_id: str, **kwar headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -542,7 +541,7 @@ def get(self, resource_group_name: str, service_name: str, cache_id: str, **kwar response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CacheContract", pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -658,7 +657,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -694,7 +693,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -710,15 +708,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("CacheContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CacheContract", pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -825,7 +817,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -861,7 +853,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -879,7 +870,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CacheContract", pipeline_response) + deserialized = self._deserialize("CacheContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -907,7 +898,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -931,7 +922,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py index 951dd6574581..eb3780f728f1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -101,7 +104,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +127,7 @@ def build_get_entity_tag_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -144,7 +147,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -167,7 +170,7 @@ def build_get_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -193,7 +196,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -217,7 +220,7 @@ def build_create_or_update_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -247,7 +250,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -270,7 +273,7 @@ def build_delete_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -291,7 +294,7 @@ def build_refresh_secret_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -314,7 +317,7 @@ def build_refresh_secret_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -389,7 +392,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CertificateCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -412,7 +415,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -428,7 +430,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -474,7 +475,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, certificat :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -497,7 +498,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, certificat headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -537,7 +537,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -560,7 +560,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -578,7 +577,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CertificateContract", pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -698,7 +697,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -734,7 +733,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -750,15 +748,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("CertificateContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CertificateContract", pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -786,7 +778,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -810,7 +802,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -850,7 +841,7 @@ def refresh_secret( :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -873,7 +864,6 @@ def refresh_secret( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -891,7 +881,7 @@ def refresh_secret( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("CertificateContract", pipeline_response) + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py index 61993a3adead..e7f21aad4403 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +46,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +67,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -89,7 +92,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +114,7 @@ def build_get_entity_tag_request( ), "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str", max_length=80, min_length=1), "contentItemId": _SERIALIZER.url("content_item_id", content_item_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -136,7 +139,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +161,7 @@ def build_get_request( ), "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str", max_length=80, min_length=1), "contentItemId": _SERIALIZER.url("content_item_id", content_item_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -185,7 +188,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -208,7 +211,7 @@ def build_create_or_update_request( ), "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str", max_length=80, min_length=1), "contentItemId": _SERIALIZER.url("content_item_id", content_item_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -239,7 +242,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -261,7 +264,7 @@ def build_delete_request( ), "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str", max_length=80, min_length=1), "contentItemId": _SERIALIZER.url("content_item_id", content_item_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -318,7 +321,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContentItemCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -338,7 +341,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -354,7 +356,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -404,7 +405,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -428,7 +429,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -469,7 +469,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -493,7 +493,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -511,7 +510,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ContentItemContract", pipeline_response) + deserialized = self._deserialize("ContentItemContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -624,7 +623,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -661,7 +660,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -677,15 +675,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ContentItemContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ContentItemContract", pipeline_response) + deserialized = self._deserialize("ContentItemContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -720,7 +712,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -745,7 +737,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py index d8f9d7e5aceb..4470f8966a97 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +46,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +66,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -83,7 +86,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,7 +107,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -130,7 +133,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -152,7 +155,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -182,7 +185,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,7 +206,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -259,7 +262,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContentTypeCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -278,7 +281,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -294,7 +296,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -342,7 +343,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,7 +366,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -383,7 +383,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ContentTypeContract", pipeline_response) + deserialized = self._deserialize("ContentTypeContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -493,7 +493,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -529,7 +529,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -545,15 +544,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ContentTypeContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ContentTypeContract", pipeline_response) + deserialized = self._deserialize("ContentTypeContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -582,7 +575,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -606,7 +599,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py index ab37ece18239..af0d22ce16ae 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +64,7 @@ def build_get_entity_tag_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -79,7 +82,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +102,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -119,7 +122,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -140,7 +143,7 @@ def build_update_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -163,7 +166,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -184,7 +187,7 @@ def build_create_or_update_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -208,7 +211,7 @@ def build_list_secrets_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -228,7 +231,7 @@ def build_list_secrets_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -274,7 +277,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -296,7 +299,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -331,7 +333,7 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -353,7 +355,6 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -371,7 +372,7 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalDelegationSettings", pipeline_response) + deserialized = self._deserialize("PortalDelegationSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -466,7 +467,7 @@ def update( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,7 +502,6 @@ def update( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -607,7 +607,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -642,7 +642,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -657,7 +656,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalDelegationSettings", pipeline_response) + deserialized = self._deserialize("PortalDelegationSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -679,7 +678,7 @@ def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -701,7 +700,6 @@ def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -716,7 +714,7 @@ def list_secrets( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalSettingValidationKeyContract", pipeline_response) + deserialized = self._deserialize("PortalSettingValidationKeyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py index d2ca5479aa3c..baefd8adffb3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import sys +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.exceptions import ( @@ -15,13 +16,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,8 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,7 +55,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices" ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -68,7 +73,7 @@ def build_get_by_name_request(service_name: str, location: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_get_by_name_request(service_name: str, location: str, subscription_id: min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), } @@ -104,7 +109,7 @@ def build_purge_request(service_name: str, location: str, subscription_id: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +126,7 @@ def build_purge_request(service_name: str, location: str, subscription_id: str, min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), } @@ -170,7 +175,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DeletedServic api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedServicesCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,7 +192,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -203,7 +207,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -245,7 +248,7 @@ def get_by_name(self, service_name: str, location: str, **kwargs: Any) -> _model :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -267,7 +270,6 @@ def get_by_name(self, service_name: str, location: str, **kwargs: Any) -> _model headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -282,17 +284,15 @@ def get_by_name(self, service_name: str, location: str, **kwargs: Any) -> _model error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedServiceContract", pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _purge_initial( - self, service_name: str, location: str, **kwargs: Any - ) -> Optional[_models.DeletedServiceContract]: - error_map = { + def _purge_initial(self, service_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -304,7 +304,7 @@ def _purge_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.DeletedServiceContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_purge_request( service_name=service_name, @@ -314,10 +314,10 @@ def _purge_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -325,16 +325,19 @@ def _purge_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("DeletedServiceContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -372,6 +375,7 @@ def begin_purge(self, service_name: str, location: str, **kwargs: Any) -> LROPol params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -379,7 +383,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("DeletedServiceContract", pipeline_response) + deserialized = self._deserialize("DeletedServiceContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py index ca50590197ed..f9695c804770 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +122,7 @@ def build_get_entity_tag_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -139,7 +142,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +165,7 @@ def build_get_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -188,7 +191,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -212,7 +215,7 @@ def build_create_or_update_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -242,7 +245,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -266,7 +269,7 @@ def build_update_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -295,7 +298,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -318,7 +321,7 @@ def build_delete_request( "diagnosticId": _SERIALIZER.url( "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -388,7 +391,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DiagnosticCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,7 +413,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -426,7 +428,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -472,7 +473,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, diagnostic :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -495,7 +496,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, diagnostic headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -535,7 +535,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -558,7 +558,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -576,7 +575,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -683,7 +682,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -719,7 +718,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -735,15 +733,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("DiagnosticContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -850,7 +842,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,7 +878,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -904,7 +895,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DiagnosticContract", pipeline_response) + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -932,7 +923,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -956,7 +947,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_documentation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_documentation_operations.py index a3f8fa923115..bca56a18dba6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_documentation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_documentation_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +122,7 @@ def build_get_entity_tag_request( "documentationId": _SERIALIZER.url( "documentation_id", documentation_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -139,7 +142,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +165,7 @@ def build_get_request( "documentationId": _SERIALIZER.url( "documentation_id", documentation_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -188,7 +191,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -212,7 +215,7 @@ def build_create_or_update_request( "documentationId": _SERIALIZER.url( "documentation_id", documentation_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -242,7 +245,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -266,7 +269,7 @@ def build_update_request( "documentationId": _SERIALIZER.url( "documentation_id", documentation_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -295,7 +298,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -318,7 +321,7 @@ def build_delete_request( "documentationId": _SERIALIZER.url( "documentation_id", documentation_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -388,7 +391,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DocumentationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,7 +413,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -426,7 +428,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -472,7 +473,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, documentat :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -495,7 +496,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, documentat headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -535,7 +535,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -558,7 +558,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -576,7 +575,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DocumentationContract", pipeline_response) + deserialized = self._deserialize("DocumentationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -683,7 +682,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -719,7 +718,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -735,15 +733,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("DocumentationContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DocumentationContract", pipeline_response) + deserialized = self._deserialize("DocumentationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -850,7 +842,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,7 +878,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -904,7 +895,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("DocumentationContract", pipeline_response) + deserialized = self._deserialize("DocumentationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -932,7 +923,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -956,7 +947,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py index 6329a5cb4fe8..4e236da87a6d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -100,7 +103,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +124,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "templateName": _SERIALIZER.url("template_name", template_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -145,7 +148,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,7 +169,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "templateName": _SERIALIZER.url("template_name", template_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -192,7 +195,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -214,7 +217,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "templateName": _SERIALIZER.url("template_name", template_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -244,7 +247,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -266,7 +269,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "templateName": _SERIALIZER.url("template_name", template_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -295,7 +298,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -316,7 +319,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "templateName": _SERIALIZER.url("template_name", template_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -387,7 +390,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EmailTemplateCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,7 +412,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -425,7 +427,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -483,7 +484,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -506,7 +507,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -556,7 +556,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -579,7 +579,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -597,7 +596,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("EmailTemplateContract", pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -722,7 +721,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,7 +757,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -773,11 +771,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("EmailTemplateContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("EmailTemplateContract", pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -902,7 +896,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -938,7 +932,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -956,7 +949,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("EmailTemplateContract", pipeline_response) + deserialized = self._deserialize("EmailTemplateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -995,7 +988,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1019,7 +1012,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py index 28885b7ab3fa..7a5fda7425f1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -98,7 +101,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +123,7 @@ def build_get_entity_tag_request( ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -140,7 +143,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -163,7 +166,7 @@ def build_create_or_update_request( ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -185,7 +188,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -207,7 +210,7 @@ def build_delete_request( ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -280,7 +283,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +306,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -319,7 +321,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -370,7 +371,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -394,7 +395,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -516,7 +516,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -555,7 +555,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -570,11 +569,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApiContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -602,7 +597,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -626,7 +621,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py index 5433df4c9733..30db6be5e670 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -103,7 +106,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +130,7 @@ def build_get_entity_tag_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -152,7 +155,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -176,7 +179,7 @@ def build_get_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -203,7 +206,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -228,7 +231,7 @@ def build_create_or_update_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -259,7 +262,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -283,7 +286,7 @@ def build_delete_request( "certificateId": _SERIALIZER.url( "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -358,7 +361,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GatewayCertificateAuthorityCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -381,7 +384,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -397,7 +399,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -448,7 +449,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,7 +473,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -515,7 +515,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -539,7 +539,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -557,7 +556,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -677,7 +676,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -714,7 +713,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -730,15 +728,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response) + deserialized = self._deserialize("GatewayCertificateAuthorityContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -775,7 +767,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -800,7 +792,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py index f8cb8c8d17ce..2aa65f2dc8f0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -98,7 +101,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +123,7 @@ def build_get_entity_tag_request( ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), "hcId": _SERIALIZER.url("hc_id", hc_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -140,7 +143,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +165,7 @@ def build_get_request( ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), "hcId": _SERIALIZER.url("hc_id", hc_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -189,7 +192,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -212,7 +215,7 @@ def build_create_or_update_request( ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), "hcId": _SERIALIZER.url("hc_id", hc_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -243,7 +246,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -265,7 +268,7 @@ def build_delete_request( ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), "hcId": _SERIALIZER.url("hc_id", hc_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -342,7 +345,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GatewayHostnameConfigurationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,7 +368,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -381,7 +383,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -433,7 +434,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -457,7 +458,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -500,7 +500,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,7 +524,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -542,7 +541,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -662,7 +661,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -699,7 +698,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -715,15 +713,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response) + deserialized = self._deserialize("GatewayHostnameConfigurationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -754,7 +746,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -779,7 +771,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py index c2f420414748..515007839e06 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +120,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +161,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +187,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -206,7 +209,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -230,7 +233,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -252,7 +255,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -275,7 +278,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +299,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -317,7 +320,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -338,7 +341,7 @@ def build_list_keys_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -358,7 +361,7 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -380,7 +383,7 @@ def build_regenerate_key_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -402,7 +405,7 @@ def build_generate_token_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -424,7 +427,136 @@ def build_generate_token_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_invalidate_debug_credentials_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/invalidateDebugCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_debug_credentials_request( + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listDebugCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_trace_request( + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listTrace", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -497,7 +629,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GatewayCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -519,7 +651,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -535,7 +666,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -581,7 +711,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, gateway_id :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -604,7 +734,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, gateway_id headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -644,7 +773,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -667,7 +796,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -685,7 +813,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayContract", pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -791,7 +919,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -827,7 +955,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -843,15 +970,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GatewayContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayContract", pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -957,7 +1078,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -993,7 +1114,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1011,7 +1131,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayContract", pipeline_response) + deserialized = self._deserialize("GatewayContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1039,7 +1159,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1063,7 +1183,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1099,7 +1218,7 @@ def list_keys( :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1122,7 +1241,6 @@ def list_keys( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1140,7 +1258,7 @@ def list_keys( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GatewayKeysContract", pipeline_response) + deserialized = self._deserialize("GatewayKeysContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1236,7 +1354,7 @@ def regenerate_key( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1271,7 +1389,6 @@ def regenerate_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1376,7 +1493,7 @@ def generate_token( :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1411,7 +1528,6 @@ def generate_token( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1426,7 +1542,354 @@ def generate_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GatewayTokenContract", pipeline_response) + deserialized = self._deserialize("GatewayTokenContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def invalidate_debug_credentials( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any + ) -> None: + """Action is invalidating all debug credentials issued for gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_invalidate_debug_credentials_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def list_debug_credentials( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayListDebugCredentialsContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayDebugCredentialsContract: + """Create new debug credentials for gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List debug credentials properties. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayDebugCredentialsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_debug_credentials( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayDebugCredentialsContract: + """Create new debug credentials for gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List debug credentials properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayDebugCredentialsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_debug_credentials( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayListDebugCredentialsContract, IO[bytes]], + **kwargs: Any + ) -> _models.GatewayDebugCredentialsContract: + """Create new debug credentials for gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List debug credentials properties. Is either a + GatewayListDebugCredentialsContract type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContract or + IO[bytes] + :return: GatewayDebugCredentialsContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayDebugCredentialsContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayListDebugCredentialsContract") + + _request = build_list_debug_credentials_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GatewayDebugCredentialsContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def list_trace( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayListTraceContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Dict[str, Any]: + """Fetches trace collected by gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List trace properties. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListTraceContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to any or the result of cls(response) + :rtype: dict[str, any] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_trace( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Dict[str, Any]: + """Fetches trace collected by gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List trace properties. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: dict mapping str to any or the result of cls(response) + :rtype: dict[str, any] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_trace( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayListTraceContract, IO[bytes]], + **kwargs: Any + ) -> Dict[str, Any]: + """Fetches trace collected by gateway. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. Required. + :type gateway_id: str + :param parameters: List trace properties. Is either a GatewayListTraceContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListTraceContract or IO[bytes] + :return: dict mapping str to any or the result of cls(response) + :rtype: dict[str, any] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Dict[str, Any]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GatewayListTraceContract") + + _request = build_list_trace_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("{object}", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py index c98d4a466ec2..7db0d8bc8487 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +57,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +77,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -98,7 +103,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +124,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -139,7 +144,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +165,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -186,7 +191,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -208,7 +213,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -232,7 +237,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -253,7 +258,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -324,7 +329,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GlobalSchemaCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -346,7 +351,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -362,7 +366,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -408,7 +411,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, schema_id: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,7 +434,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, schema_id: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -471,7 +473,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -494,7 +496,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -512,7 +513,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -527,8 +528,8 @@ def _create_or_update_initial( parameters: Union[_models.GlobalSchemaContract, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.GlobalSchemaContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,7 +542,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.GlobalSchemaContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -564,32 +565,33 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -722,14 +724,19 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("GlobalSchemaContract", pipeline_response) + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -774,7 +781,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -798,7 +805,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_operations.py index 65c1d2606de9..77b2f03a94ee 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_api_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -98,7 +101,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +123,7 @@ def build_get_entity_tag_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -140,7 +143,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +165,7 @@ def build_get_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -189,7 +192,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -212,7 +215,7 @@ def build_create_or_update_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -243,7 +246,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -266,7 +269,7 @@ def build_update_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -296,7 +299,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -318,7 +321,7 @@ def build_delete_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -395,7 +398,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResolverCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,7 +421,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -434,7 +436,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -485,7 +486,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -509,7 +510,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -552,7 +552,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.ResolverContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -576,7 +576,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -594,7 +593,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ResolverContract", pipeline_response) + deserialized = self._deserialize("ResolverContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -713,7 +712,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ResolverContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -750,7 +749,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -766,15 +764,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ResolverContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ResolverContract", pipeline_response) + deserialized = self._deserialize("ResolverContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -893,7 +885,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.ResolverContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -930,7 +922,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -948,7 +939,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ResolverContract", pipeline_response) + deserialized = self._deserialize("ResolverContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -979,7 +970,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1004,7 +995,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_policy_operations.py index 3c057a54e7da..6066f6dcabfc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_policy_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +46,7 @@ def build_list_by_resolver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +68,7 @@ def build_list_by_resolver_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -91,7 +94,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +117,7 @@ def build_get_entity_tag_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -142,7 +145,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -165,7 +168,7 @@ def build_get_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -195,7 +198,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -219,7 +222,7 @@ def build_create_or_update_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -251,7 +254,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -274,7 +277,7 @@ def build_delete_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str", max_length=80, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -335,7 +338,7 @@ def list_by_resolver( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -356,7 +359,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -372,7 +374,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -432,7 +433,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -457,7 +458,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -512,7 +512,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -538,7 +538,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -556,7 +555,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -684,7 +683,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -722,7 +721,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -738,15 +736,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -786,7 +778,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,7 +804,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py index 98474003b482..b77c31567adc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +120,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +161,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +187,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -206,7 +209,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -230,7 +233,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -252,7 +255,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -275,7 +278,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +299,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -371,7 +374,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -393,7 +396,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -409,7 +411,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -455,7 +456,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, group_id: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,7 +479,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, group_id: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -516,7 +516,7 @@ def get(self, resource_group_name: str, service_name: str, group_id: str, **kwar :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -539,7 +539,6 @@ def get(self, resource_group_name: str, service_name: str, group_id: str, **kwar headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -557,7 +556,7 @@ def get(self, resource_group_name: str, service_name: str, group_id: str, **kwar response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GroupContract", pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -664,7 +663,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -700,7 +699,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -716,15 +714,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("GroupContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GroupContract", pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -831,7 +823,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -867,7 +859,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -885,7 +876,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("GroupContract", pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -913,7 +904,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -937,7 +928,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py index dfd484e2f246..7df973e849c8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -97,7 +100,7 @@ def build_check_entity_exists_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +122,7 @@ def build_check_entity_exists_request( ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -139,7 +142,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +164,7 @@ def build_create_request( ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -181,7 +184,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,7 +206,7 @@ def build_delete_request( ), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -280,7 +283,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UserCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +306,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -319,7 +321,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -370,7 +371,7 @@ def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -394,7 +395,6 @@ def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -434,7 +434,7 @@ def create( :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +458,6 @@ def create( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -473,11 +472,7 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("UserContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("UserContract", pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -505,7 +500,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -529,7 +524,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py index d2911956e421..75535bc3b5e5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +46,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +66,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -87,7 +90,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,7 +111,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -132,7 +135,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -153,7 +156,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -179,7 +182,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -201,7 +204,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -231,7 +234,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -253,7 +256,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -282,7 +285,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -303,7 +306,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -328,7 +331,7 @@ def build_list_secrets_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -349,7 +352,7 @@ def build_list_secrets_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -408,7 +411,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IdentityProviderList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -427,7 +430,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -443,7 +445,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -495,7 +496,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -518,7 +519,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -563,7 +563,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -586,7 +586,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -604,7 +603,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IdentityProviderContract", pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -711,7 +710,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -747,7 +746,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -763,15 +761,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IdentityProviderContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IdentityProviderContract", pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -879,7 +871,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,7 +907,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -933,7 +924,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IdentityProviderContract", pipeline_response) + deserialized = self._deserialize("IdentityProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -966,7 +957,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -990,7 +981,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1030,7 +1020,7 @@ def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1053,7 +1043,6 @@ def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1071,7 +1060,7 @@ def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ClientSecretContract", pipeline_response) + deserialized = self._deserialize("ClientSecretContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py index 2544e79f662f..9055f5976efe 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +72,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -95,7 +98,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +121,7 @@ def build_get_request( "issueId": _SERIALIZER.url( "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -191,7 +194,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IssueCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,7 +216,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -229,7 +231,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -275,7 +276,7 @@ def get(self, resource_group_name: str, service_name: str, issue_id: str, **kwar :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,7 +299,6 @@ def get(self, resource_group_name: str, service_name: str, issue_id: str, **kwar headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -316,7 +316,7 @@ def get(self, resource_group_name: str, service_name: str, issue_id: str, **kwar response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("IssueContract", pipeline_response) + deserialized = self._deserialize("IssueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py index 282deb89a865..d17766462498 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +120,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +161,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +187,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -206,7 +209,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -230,7 +233,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -252,7 +255,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -275,7 +278,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +299,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -371,7 +374,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LoggerCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -393,7 +396,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -409,7 +411,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -455,7 +456,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, logger_id: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,7 +479,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, logger_id: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -516,7 +516,7 @@ def get(self, resource_group_name: str, service_name: str, logger_id: str, **kwa :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -539,7 +539,6 @@ def get(self, resource_group_name: str, service_name: str, logger_id: str, **kwa headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -557,7 +556,7 @@ def get(self, resource_group_name: str, service_name: str, logger_id: str, **kwa response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("LoggerContract", pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -664,7 +663,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -700,7 +699,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -716,15 +714,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("LoggerContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("LoggerContract", pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -831,7 +823,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -867,7 +859,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -885,7 +876,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("LoggerContract", pipeline_response) + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -913,7 +904,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -937,7 +928,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py index fc2acf5894a2..9bd3466db210 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +58,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +78,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -103,7 +108,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -126,7 +131,7 @@ def build_get_entity_tag_request( "namedValueId": _SERIALIZER.url( "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -146,7 +151,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -169,7 +174,7 @@ def build_get_request( "namedValueId": _SERIALIZER.url( "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -195,7 +200,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -219,7 +224,7 @@ def build_create_or_update_request( "namedValueId": _SERIALIZER.url( "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -249,7 +254,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -273,7 +278,7 @@ def build_update_request( "namedValueId": _SERIALIZER.url( "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -302,7 +307,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -325,7 +330,7 @@ def build_delete_request( "namedValueId": _SERIALIZER.url( "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -346,7 +351,7 @@ def build_list_value_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -369,7 +374,7 @@ def build_list_value_request( "namedValueId": _SERIALIZER.url( "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -389,7 +394,7 @@ def build_refresh_secret_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -412,7 +417,7 @@ def build_refresh_secret_request( "namedValueId": _SERIALIZER.url( "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -489,7 +494,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NamedValueCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -512,7 +517,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -528,7 +532,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -573,7 +576,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, named_valu :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -596,7 +599,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, named_valu headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -635,7 +637,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -658,7 +660,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -676,7 +677,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -691,8 +692,8 @@ def _create_or_update_initial( parameters: Union[_models.NamedValueCreateContract, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.NamedValueContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -705,7 +706,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.NamedValueContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -728,32 +729,33 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("NamedValueContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -883,14 +885,19 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -922,8 +929,8 @@ def _update_initial( if_match: str, parameters: Union[_models.NamedValueUpdateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.NamedValueContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -936,7 +943,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.NamedValueContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -959,10 +966,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -970,16 +977,25 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1109,6 +1125,7 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -1116,7 +1133,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -1160,7 +1177,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1184,7 +1201,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1219,7 +1235,7 @@ def list_value( :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1242,7 +1258,6 @@ def list_value( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1260,7 +1275,7 @@ def list_value( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueSecretContract", pipeline_response) + deserialized = self._deserialize("NamedValueSecretContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1269,8 +1284,8 @@ def list_value( def _refresh_secret_initial( self, resource_group_name: str, service_name: str, named_value_id: str, **kwargs: Any - ) -> Optional[_models.NamedValueContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1282,7 +1297,7 @@ def _refresh_secret_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.NamedValueContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_refresh_secret_request( resource_group_name=resource_group_name, @@ -1293,10 +1308,10 @@ def _refresh_secret_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1304,16 +1319,25 @@ def _refresh_secret_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1357,6 +1381,7 @@ def begin_refresh_secret( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -1364,7 +1389,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("NamedValueContract", pipeline_response) + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py index 8e6fb3339d2b..91a23cde5a09 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, List, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, List, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +52,7 @@ def build_list_by_service_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -80,7 +83,7 @@ def build_list_by_location_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +92,7 @@ def build_list_by_location_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -151,7 +154,7 @@ def list_by_service( :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,7 +176,6 @@ def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -188,7 +190,7 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("[NetworkStatusContractByLocation]", pipeline_response) + deserialized = self._deserialize("[NetworkStatusContractByLocation]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -215,7 +217,7 @@ def list_by_location( :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,7 +240,6 @@ def list_by_location( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -253,7 +254,7 @@ def list_by_location( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NetworkStatusContract", pipeline_response) + deserialized = self._deserialize("NetworkStatusContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py index 49841dd6dd56..4487b3721d86 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +51,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +71,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +120,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -143,7 +146,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +167,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -230,7 +233,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NotificationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,7 +254,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -267,7 +269,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -321,7 +322,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.NotificationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,7 +345,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -359,7 +359,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NotificationContract", pipeline_response) + deserialized = self._deserialize("NotificationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -394,7 +394,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.NotificationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,7 +418,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -433,7 +432,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NotificationContract", pipeline_response) + deserialized = self._deserialize("NotificationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py index d4f0596ab91c..3ce8af308b65 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +47,7 @@ def build_list_by_notification_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +68,7 @@ def build_list_by_notification_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -90,7 +93,7 @@ def build_check_entity_exists_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +115,7 @@ def build_check_entity_exists_request( ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), "email": _SERIALIZER.url("email", email, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,7 +162,7 @@ def build_create_or_update_request( ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), "email": _SERIALIZER.url("email", email, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +187,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -206,7 +209,7 @@ def build_delete_request( ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), "email": _SERIALIZER.url("email", email, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -263,7 +266,7 @@ def list_by_notification( :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,7 +289,6 @@ def list_by_notification( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,7 +303,7 @@ def list_by_notification( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecipientEmailCollection", pipeline_response) + deserialized = self._deserialize("RecipientEmailCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -335,7 +337,7 @@ def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +361,6 @@ def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -405,7 +406,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -429,7 +430,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -444,11 +444,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecipientEmailContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecipientEmailContract", pipeline_response) + deserialized = self._deserialize("RecipientEmailContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -482,7 +478,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -506,7 +502,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py index 788581fdc9e5..ec602eca2862 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +47,7 @@ def build_list_by_notification_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +68,7 @@ def build_list_by_notification_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -90,7 +93,7 @@ def build_check_entity_exists_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +115,7 @@ def build_check_entity_exists_request( ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,7 +162,7 @@ def build_create_or_update_request( ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +187,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -206,7 +209,7 @@ def build_delete_request( ), "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -263,7 +266,7 @@ def list_by_notification( :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -286,7 +289,6 @@ def list_by_notification( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -301,7 +303,7 @@ def list_by_notification( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecipientUserCollection", pipeline_response) + deserialized = self._deserialize("RecipientUserCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -336,7 +338,7 @@ def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,7 +362,6 @@ def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -407,7 +408,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,7 +432,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -446,11 +446,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RecipientUserContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RecipientUserContract", pipeline_response) + deserialized = self._deserialize("RecipientUserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -485,7 +481,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -509,7 +505,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py index 28044167dabb..426ac3dc252a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +120,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +161,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +187,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -206,7 +209,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -230,7 +233,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -252,7 +255,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -275,7 +278,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +299,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -317,7 +320,7 @@ def build_list_secrets_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -338,7 +341,7 @@ def build_list_secrets_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "opid": _SERIALIZER.url("opid", opid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -410,7 +413,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OpenIdConnectProviderCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,7 +435,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -448,7 +450,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -493,7 +494,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, opid: str, :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -516,7 +517,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, opid: str, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -555,7 +555,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -578,7 +578,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -596,7 +595,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -700,7 +699,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -736,7 +735,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -752,15 +750,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -865,7 +857,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -901,7 +893,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -919,7 +910,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response) + deserialized = self._deserialize("OpenidConnectProviderContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -946,7 +937,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -970,7 +961,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1005,7 +995,7 @@ def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1028,7 +1018,6 @@ def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1046,7 +1035,7 @@ def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ClientSecretContract", pipeline_response) + deserialized = self._deserialize("ClientSecretContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py index ef0d82d8af44..4154954f54e7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_tags_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_tags_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -163,7 +166,7 @@ def list_by_tags( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagResourceCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,7 +190,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -203,7 +205,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_status_operations.py new file mode 100644 index 000000000000..5b8cd277911e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_status_operations.py @@ -0,0 +1,141 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(location: str, operation_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/operationStatuses/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: + """Returns the current status of an async operation. + + :param location: The name of the Azure region. Required. + :type location: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationStatusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operations_results_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operations_results_operations.py new file mode 100644 index 000000000000..bdb9a7e95818 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operations_results_operations.py @@ -0,0 +1,144 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(location: str, operation_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/operationResults/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OperationsResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`operations_results` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( # pylint: disable=inconsistent-return-statements + self, location: str, operation_id: str, **kwargs: Any + ) -> None: + """Returns operation results for long running operations executing DELETE or PATCH on the + resource. + + :param location: The name of the Azure region. Required. + :type location: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py index 0bd550934915..e7761895147b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +52,7 @@ def build_list_by_service_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -108,7 +111,7 @@ def list_by_service( :rtype: ~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,7 +133,6 @@ def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,7 +147,7 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OutboundEnvironmentEndpointList", pipeline_response) + deserialized = self._deserialize("OutboundEnvironmentEndpointList", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py index 7fb691c99793..9bcf096911c5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +48,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +68,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -122,7 +125,7 @@ def list_by_service( :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -145,7 +148,6 @@ def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -160,7 +162,7 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyDescriptionCollection", pipeline_response) + deserialized = self._deserialize("PolicyDescriptionCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py index c6a8522dfbb5..7dfc30f01504 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py @@ -7,7 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +58,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +78,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -99,7 +106,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +127,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -146,7 +153,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -167,7 +174,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -195,7 +202,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -217,7 +224,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -241,7 +248,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -262,7 +269,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -290,7 +297,7 @@ def build_list_references_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -311,7 +318,7 @@ def build_list_references_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -358,7 +365,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> _models.PolicyFragmentCollection: + ) -> Iterable["_models.PolicyFragmentContract"]: """Gets all policy fragments. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -379,57 +386,83 @@ def list_by_service( :type top: int :param skip: Number of records to skip. Default value is None. :type skip: int - :return: PolicyFragmentCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentCollection + :return: An iterator like instance of either PolicyFragmentContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyFragmentContract] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyFragmentCollection] = kwargs.pop("cls", None) - _request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - orderby=orderby, - top=top, - skip=skip, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyFragmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + _request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("PolicyFragmentCollection", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) @distributed_trace def get_entity_tag(self, resource_group_name: str, service_name: str, id: str, **kwargs: Any) -> bool: @@ -446,7 +479,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, id: str, * :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,7 +502,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, id: str, * headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -516,7 +548,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -540,7 +572,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -558,7 +589,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyFragmentContract", pipeline_response) + deserialized = self._deserialize("PolicyFragmentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -573,8 +604,8 @@ def _create_or_update_initial( parameters: Union[_models.PolicyFragmentContract, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.PolicyFragmentContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -587,7 +618,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PolicyFragmentContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -610,35 +641,33 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyFragmentContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyFragmentContract", pipeline_response) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -768,14 +797,19 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("PolicyFragmentContract", pipeline_response) + deserialized = self._deserialize("PolicyFragmentContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -819,7 +853,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +877,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -888,7 +921,7 @@ def list_references( :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -913,7 +946,6 @@ def list_references( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -928,7 +960,7 @@ def list_references( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceCollection", pipeline_response) + deserialized = self._deserialize("ResourceCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py index 13fe9cf1df30..8c6db5059acd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py @@ -7,7 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +19,20 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +46,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +66,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -85,7 +90,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +111,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -132,7 +137,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -153,7 +158,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -181,7 +186,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +208,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -233,7 +238,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -254,7 +259,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -289,7 +294,9 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_service(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.PolicyCollection: + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.PolicyContract"]: """Lists all the Global Policy definitions of the Api Management service. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -297,53 +304,78 @@ def list_by_service(self, resource_group_name: str, service_name: str, **kwargs: :type resource_group_name: str :param service_name: The name of the API Management service. Required. :type service_name: str - :return: PolicyCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) - _request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - return deserialized # type: ignore + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get_entity_tag( @@ -363,7 +395,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,7 +418,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -433,7 +464,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -457,7 +488,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -475,7 +505,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -579,7 +609,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -615,7 +645,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -631,15 +660,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -671,7 +694,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -695,7 +718,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_operations.py new file mode 100644 index 000000000000..74c7d5423b6d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_operations.py @@ -0,0 +1,935 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, policy_restriction_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "policyRestrictionId": _SERIALIZER.url( + "policy_restriction_id", policy_restriction_id, "str", max_length=80, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, policy_restriction_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "policyRestrictionId": _SERIALIZER.url( + "policy_restriction_id", policy_restriction_id, "str", max_length=80, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "policyRestrictionId": _SERIALIZER.url( + "policy_restriction_id", policy_restriction_id, "str", max_length=80, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "policyRestrictionId": _SERIALIZER.url( + "policy_restriction_id", policy_restriction_id, "str", max_length=80, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "policyRestrictionId": _SERIALIZER.url( + "policy_restriction_id", policy_restriction_id, "str", max_length=80, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PolicyRestrictionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`policy_restriction` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.PolicyRestrictionContract"]: + """Gets all policy restrictions of API Management services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An iterator like instance of either PolicyRestrictionContract or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyRestrictionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyRestrictionCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyRestrictionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, policy_restriction_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the policy restriction in the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, policy_restriction_id: str, **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Get the policy restriction of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyRestrictionContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyRestrictionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + parameters: _models.PolicyRestrictionContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Creates or updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param parameters: The policy restriction to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Creates or updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param parameters: The policy restriction to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + parameters: Union[_models.PolicyRestrictionContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Creates or updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param parameters: The policy restriction to apply. Is either a PolicyRestrictionContract type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyRestrictionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyRestrictionContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyRestrictionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + if_match: str, + parameters: _models.PolicyRestrictionUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: The policy restriction to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: The policy restriction to apply. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + if_match: str, + parameters: Union[_models.PolicyRestrictionUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.PolicyRestrictionContract: + """Updates the policy restriction configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: The policy restriction to apply. Is either a PolicyRestrictionUpdateContract + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract or IO[bytes] + :return: PolicyRestrictionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyRestrictionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyRestrictionUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyRestrictionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes the policy restriction configuration of the Api Management Service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param policy_restriction_id: Policy restrictions after an entity level. Required. + :type policy_restriction_id: str + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_validations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_validations_operations.py new file mode 100644 index 000000000000..17d967e07f99 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_validations_operations.py @@ -0,0 +1,216 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterator, Optional, Type, TypeVar, Union, cast + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_by_service_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/validatePolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class PolicyRestrictionValidationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`policy_restriction_validations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _by_service_initial(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """Validate all policies of API Management services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :return: An instance of LROPoller that returns either OperationResultContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationResultContract] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._by_service_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("OperationResultContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OperationResultContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationResultContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_config_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_config_operations.py index f0f8123bec04..03af46015703 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_config_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_config_operations.py @@ -7,7 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +19,20 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +46,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +66,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -81,7 +86,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +95,7 @@ def build_get_entity_tag_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -122,7 +127,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,7 +136,7 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -169,7 +174,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -179,7 +184,7 @@ def build_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -220,7 +225,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -230,7 +235,7 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -281,7 +286,7 @@ def __init__(self, *args, **kwargs): @distributed_trace def list_by_service( self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.PortalConfigCollection: + ) -> Iterable["_models.PortalConfigContract"]: """Lists the developer portal configurations. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -289,53 +294,79 @@ def list_by_service( :type resource_group_name: str :param service_name: The name of the API Management service. Required. :type service_name: str - :return: PortalConfigCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigCollection + :return: An iterator like instance of either PortalConfigContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PortalConfigContract] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PortalConfigCollection] = kwargs.pop("cls", None) - _request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PortalConfigCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - return deserialized # type: ignore + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PortalConfigCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get_entity_tag(self, resource_group_name: str, service_name: str, portal_config_id: str, **kwargs: Any) -> bool: @@ -352,7 +383,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, portal_con :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +406,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, portal_con headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -414,7 +444,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -437,7 +467,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -455,7 +484,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalConfigContract", pipeline_response) + deserialized = self._deserialize("PortalConfigContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -559,7 +588,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -595,7 +624,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -610,7 +638,7 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalConfigContract", pipeline_response) + deserialized = self._deserialize("PortalConfigContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -714,7 +742,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -750,7 +778,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -765,7 +792,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalConfigContract", pipeline_response) + deserialized = self._deserialize("PortalConfigContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py index 321c745a9057..433871259ab1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +57,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +77,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -98,7 +103,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +126,7 @@ def build_get_entity_tag_request( "portalRevisionId": _SERIALIZER.url( "portal_revision_id", portal_revision_id, "str", max_length=256, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -141,7 +146,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +169,7 @@ def build_get_request( "portalRevisionId": _SERIALIZER.url( "portal_revision_id", portal_revision_id, "str", max_length=256, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -184,7 +189,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -208,7 +213,7 @@ def build_create_or_update_request( "portalRevisionId": _SERIALIZER.url( "portal_revision_id", portal_revision_id, "str", max_length=256, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -236,7 +241,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -260,7 +265,7 @@ def build_update_request( "portalRevisionId": _SERIALIZER.url( "portal_revision_id", portal_revision_id, "str", max_length=256, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -341,7 +346,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PortalRevisionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,7 +368,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -379,7 +383,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -427,7 +430,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -450,7 +453,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -490,7 +492,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -513,7 +515,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -531,7 +532,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + deserialized = self._deserialize("PortalRevisionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -545,8 +546,8 @@ def _create_or_update_initial( portal_revision_id: str, parameters: Union[_models.PortalRevisionContract, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PortalRevisionContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,7 +560,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PortalRevisionContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -581,27 +582,33 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [201, 202]: + if response.status_code not in [201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -723,14 +730,19 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + deserialized = self._deserialize("PortalRevisionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -762,8 +774,8 @@ def _update_initial( if_match: str, parameters: Union[_models.PortalRevisionContract, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PortalRevisionContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -776,7 +788,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PortalRevisionContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -799,10 +811,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -810,16 +822,25 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -951,6 +972,7 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -958,7 +980,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalRevisionContract", pipeline_response) + deserialized = self._deserialize("PortalRevisionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py index 7dfe53efa777..575c69031974 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,7 +63,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -108,7 +111,7 @@ def list_by_service( :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,7 +133,6 @@ def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -145,7 +147,7 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalSettingsCollection", pipeline_response) + deserialized = self._deserialize("PortalSettingsCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py index 7fe3dfb4b125..2af3715da8c5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +59,7 @@ def build_list_by_service_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -89,7 +94,7 @@ def build_get_by_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +117,7 @@ def build_get_by_name_request( "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -136,7 +141,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -160,7 +165,7 @@ def build_create_or_update_request( "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -186,7 +191,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -209,7 +214,7 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url( "private_endpoint_connection_name", private_endpoint_connection_name, "str" ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -229,7 +234,7 @@ def build_list_private_link_resources_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -241,7 +246,7 @@ def build_list_private_link_resources_request( # pylint: disable=name-too-long "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "serviceName": _SERIALIZER.url( "service_name", service_name, @@ -273,7 +278,7 @@ def build_get_private_link_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -285,7 +290,7 @@ def build_get_private_link_resource_request( "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "serviceName": _SERIALIZER.url( "service_name", service_name, @@ -352,7 +357,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -371,7 +376,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -387,7 +391,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -434,7 +437,7 @@ def get_by_name( :rtype: ~azure.mgmt.apimanagement.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -457,7 +460,6 @@ def get_by_name( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -472,7 +474,7 @@ def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -486,8 +488,8 @@ def _create_or_update_initial( private_endpoint_connection_name: str, private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +502,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -522,10 +524,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -533,16 +535,22 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -661,10 +669,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -686,10 +695,10 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -701,7 +710,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -712,10 +721,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -723,12 +732,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -756,7 +777,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -766,6 +787,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -802,7 +824,7 @@ def list_private_link_resources( :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -824,7 +846,6 @@ def list_private_link_resources( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -839,7 +860,7 @@ def list_private_link_resources( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -863,7 +884,7 @@ def get_private_link_resource( :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -886,7 +907,6 @@ def get_private_link_resource( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -901,7 +921,7 @@ def get_private_link_resource( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_link_operations.py new file mode 100644 index 000000000000..f851b2f1c254 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_link_operations.py @@ -0,0 +1,646 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, product_id: str, api_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, service_name: str, product_id: str, api_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, service_name: str, product_id: str, api_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ProductApiLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_api_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ProductApiLinkContract"]: + """Lists a collection of the API links associated with a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ProductApiLinkContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductApiLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductApiLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, product_id: str, api_link_id: str, **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Gets the API link for the product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_link_id: str, + parameters: _models.ProductApiLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_link_id: str, + parameters: Union[_models.ProductApiLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Is either a ProductApiLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract or IO[bytes] + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductApiLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProductApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, product_id: str, api_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified API from the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py index 98cab51788f2..53518f4cdba6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_product_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_by_product_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -97,7 +100,7 @@ def build_check_entity_exists_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +122,7 @@ def build_check_entity_exists_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -139,7 +142,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +164,7 @@ def build_create_or_update_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -181,7 +184,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,7 +206,7 @@ def build_delete_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -280,7 +283,7 @@ def list_by_product( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,7 +306,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -319,7 +321,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -370,7 +371,7 @@ def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -394,7 +395,6 @@ def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -434,7 +434,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +458,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -473,11 +472,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ApiContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ApiContract", pipeline_response) + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -505,7 +500,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -529,7 +524,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_link_operations.py new file mode 100644 index 000000000000..08d29114d095 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_link_operations.py @@ -0,0 +1,661 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "groupLinkId": _SERIALIZER.url( + "group_link_id", group_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "groupLinkId": _SERIALIZER.url( + "group_link_id", group_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "groupLinkId": _SERIALIZER.url( + "group_link_id", group_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ProductGroupLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_group_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ProductGroupLinkContract"]: + """Lists a collection of the group links associated with a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| groupId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ProductGroupLinkContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductGroupLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductGroupLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, product_id: str, group_link_id: str, **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Gets the group link for the product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductGroupLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + parameters: _models.ProductGroupLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + parameters: Union[_models.ProductGroupLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Is either a ProductGroupLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract or IO[bytes] + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductGroupLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProductGroupLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, product_id: str, group_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified group from the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py index 28c8cbc846eb..17fb7ca6862f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_by_product_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_by_product_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -97,7 +100,7 @@ def build_check_entity_exists_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +122,7 @@ def build_check_entity_exists_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -139,7 +142,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +164,7 @@ def build_create_or_update_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -181,7 +184,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,7 +206,7 @@ def build_delete_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -276,7 +279,7 @@ def list_by_product( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,7 +302,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -315,7 +317,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -366,7 +367,7 @@ def check_entity_exists( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -390,7 +391,6 @@ def check_entity_exists( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -430,7 +430,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -454,7 +454,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -469,11 +468,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("GroupContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GroupContract", pipeline_response) + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -501,7 +496,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,7 +520,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py index 707b8a0fbb52..4f8aff6faaaf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +75,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -102,7 +105,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,7 +126,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -143,7 +146,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +167,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -190,7 +193,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -212,7 +215,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -236,7 +239,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -258,7 +261,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -288,7 +291,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -309,7 +312,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -340,7 +343,7 @@ def build_list_by_tags_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -360,7 +363,7 @@ def build_list_by_tags_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -450,7 +453,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ProductCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,7 +477,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -490,7 +492,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -536,7 +537,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, product_id :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,7 +560,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, product_id headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -599,7 +599,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -622,7 +622,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -640,7 +639,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ProductContract", pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -747,7 +746,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -783,7 +782,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -799,15 +797,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ProductContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ProductContract", pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -914,7 +906,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -950,7 +942,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -968,7 +959,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("ProductContract", pipeline_response) + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1005,7 +996,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1030,7 +1021,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1091,7 +1081,7 @@ def list_by_tags( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagResourceCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1114,7 +1104,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1130,7 +1119,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py index 88a95cbe6947..b3d63572788b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py @@ -7,7 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +19,20 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +46,7 @@ def build_list_by_product_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +67,7 @@ def build_list_by_product_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -87,7 +92,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +114,7 @@ def build_get_entity_tag_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -136,7 +141,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +163,7 @@ def build_get_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -187,7 +192,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -210,7 +215,7 @@ def build_create_or_update_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -241,7 +246,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -263,7 +268,7 @@ def build_delete_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -300,7 +305,7 @@ def __init__(self, *args, **kwargs): @distributed_trace def list_by_product( self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any - ) -> _models.PolicyCollection: + ) -> Iterable["_models.PolicyContract"]: """Get the policy configuration at the Product level. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -311,54 +316,79 @@ def list_by_product( :param product_id: Product identifier. Must be unique in the current API Management service instance. Required. :type product_id: str - :return: PolicyCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) - _request = build_list_by_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - return deserialized # type: ignore + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def get_entity_tag( @@ -385,7 +415,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,7 +439,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -460,7 +489,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -485,7 +514,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -503,7 +531,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -619,7 +647,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -656,7 +684,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -672,15 +699,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("PolicyContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PolicyContract", pipeline_response) + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -716,7 +737,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -741,7 +762,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py index 9f8299e83d9b..ce6d97684f7a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -158,7 +161,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,7 +184,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -197,7 +199,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wiki_operations.py index 2ea47a95f4a8..f069fef1e2e2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wiki_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wiki_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +65,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -82,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +106,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -129,7 +132,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -151,7 +154,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -175,7 +178,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -197,7 +200,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -220,7 +223,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -241,7 +244,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -291,7 +294,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, product_id :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -314,7 +317,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, product_id headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -352,7 +354,7 @@ def get(self, resource_group_name: str, service_name: str, product_id: str, **kw :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,7 +377,6 @@ def get(self, resource_group_name: str, service_name: str, product_id: str, **kw headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -393,7 +394,7 @@ def get(self, resource_group_name: str, service_name: str, product_id: str, **kw response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -500,7 +501,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -536,7 +537,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -552,15 +552,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("WikiContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -667,7 +661,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.WikiContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -703,7 +697,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -721,7 +714,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("WikiContract", pipeline_response) + deserialized = self._deserialize("WikiContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -749,7 +742,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -773,7 +766,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wikis_operations.py index 595ebc2753af..b6820a4839ae 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wikis_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wikis_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -149,7 +152,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WikiCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,7 +175,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -188,7 +190,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py index 6db23c2bcfcb..c8dc80bb3966 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +65,7 @@ def build_list_by_service_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -82,7 +85,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -104,7 +107,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -164,7 +167,7 @@ def list_by_service( :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,7 +190,6 @@ def list_by_service( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -202,7 +204,7 @@ def list_by_service( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaCounterCollection", pipeline_response) + deserialized = self._deserialize("QuotaCounterCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -308,7 +310,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,7 +345,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -358,7 +359,7 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaCounterCollection", pipeline_response) + deserialized = self._deserialize("QuotaCounterCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py index dbbb07428dda..04fa08b2a953 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +49,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +71,7 @@ def build_get_request( ), "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "str"), "quotaPeriodKey": _SERIALIZER.url("quota_period_key", quota_period_key, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -93,7 +96,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -116,7 +119,7 @@ def build_update_request( ), "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "str"), "quotaPeriodKey": _SERIALIZER.url("quota_period_key", quota_period_key, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -178,7 +181,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -202,7 +205,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -217,7 +219,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaCounterContract", pipeline_response) + deserialized = self._deserialize("QuotaCounterContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -329,7 +331,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,7 +367,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -380,7 +381,7 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("QuotaCounterContract", pipeline_response) + deserialized = self._deserialize("QuotaCounterContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py index 66a99f7cc09e..26da38d7a169 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +45,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +65,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -116,7 +119,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RegionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -135,7 +138,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -151,7 +153,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py index 74b98b9f016e..e8531b495f21 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +54,7 @@ def build_list_by_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_by_api_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -106,7 +109,7 @@ def build_list_by_user_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -126,7 +129,7 @@ def build_list_by_user_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -161,7 +164,7 @@ def build_list_by_operation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -181,7 +184,7 @@ def build_list_by_operation_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -216,7 +219,7 @@ def build_list_by_product_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -236,7 +239,7 @@ def build_list_by_product_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -270,7 +273,7 @@ def build_list_by_geo_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -290,7 +293,7 @@ def build_list_by_geo_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -323,7 +326,7 @@ def build_list_by_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -343,7 +346,7 @@ def build_list_by_subscription_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -379,7 +382,7 @@ def build_list_by_time_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -399,7 +402,7 @@ def build_list_by_time_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -434,7 +437,7 @@ def build_list_by_request_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -454,7 +457,7 @@ def build_list_by_request_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -529,7 +532,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -552,7 +555,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -568,7 +570,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -648,7 +649,7 @@ def list_by_user( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -671,7 +672,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -687,7 +687,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -767,7 +766,7 @@ def list_by_operation( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -790,7 +789,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -806,7 +804,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -885,7 +882,7 @@ def list_by_product( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -908,7 +905,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -924,7 +920,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1000,7 +995,7 @@ def list_by_geo( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1022,7 +1017,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1038,7 +1032,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1117,7 +1110,7 @@ def list_by_subscription( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1140,7 +1133,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1156,7 +1148,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1240,7 +1231,7 @@ def list_by_time( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1264,7 +1255,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1280,7 +1270,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1349,7 +1338,7 @@ def list_by_request( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RequestReportCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1371,7 +1360,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1387,7 +1375,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py index 1cd6b13fdbef..a625c7a9df3b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +64,7 @@ def build_get_entity_tag_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -79,7 +82,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +102,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -119,7 +122,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -140,7 +143,7 @@ def build_update_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -163,7 +166,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -184,7 +187,7 @@ def build_create_or_update_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -234,7 +237,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +259,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -291,7 +293,7 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -313,7 +315,6 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -331,7 +332,7 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalSigninSettings", pipeline_response) + deserialized = self._deserialize("PortalSigninSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -426,7 +427,7 @@ def update( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,7 +462,6 @@ def update( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -567,7 +567,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -602,7 +602,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -617,7 +616,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalSigninSettings", pipeline_response) + deserialized = self._deserialize("PortalSigninSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py index 9fb857691410..d5068935eff3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +64,7 @@ def build_get_entity_tag_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -79,7 +82,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +102,7 @@ def build_get_request(resource_group_name: str, service_name: str, subscription_ min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -119,7 +122,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -140,7 +143,7 @@ def build_update_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -163,7 +166,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -184,7 +187,7 @@ def build_create_or_update_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -234,7 +237,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +259,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -291,7 +293,7 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -313,7 +315,6 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -331,7 +332,7 @@ def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _mo response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("PortalSignupSettings", pipeline_response) + deserialized = self._deserialize("PortalSignupSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -426,7 +427,7 @@ def update( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,7 +462,6 @@ def update( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -567,7 +567,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -602,7 +602,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -617,7 +616,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PortalSignupSettings", pipeline_response) + deserialized = self._deserialize("PortalSignupSettings", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py index bbc5dd3f0737..cb1c05f97584 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_list_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,7 +99,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +120,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -137,7 +140,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +161,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -186,7 +189,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -208,7 +211,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -244,7 +247,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -266,7 +269,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -293,7 +296,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -314,7 +317,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -335,7 +338,7 @@ def build_regenerate_primary_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -356,7 +359,7 @@ def build_regenerate_primary_key_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -376,7 +379,7 @@ def build_regenerate_secondary_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -397,7 +400,7 @@ def build_regenerate_secondary_key_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -417,7 +420,7 @@ def build_list_secrets_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -438,7 +441,7 @@ def build_list_secrets_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -515,7 +518,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -537,7 +540,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -553,7 +555,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -600,7 +601,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, sid: str, :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -623,7 +624,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, sid: str, headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -661,7 +661,7 @@ def get(self, resource_group_name: str, service_name: str, sid: str, **kwargs: A :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -684,7 +684,6 @@ def get(self, resource_group_name: str, service_name: str, sid: str, **kwargs: A headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -702,7 +701,7 @@ def get(self, resource_group_name: str, service_name: str, sid: str, **kwargs: A response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionContract", pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -845,7 +844,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -883,7 +882,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -899,15 +897,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("SubscriptionContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionContract", pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1050,7 +1042,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1088,7 +1080,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1106,7 +1097,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionContract", pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1134,7 +1125,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1158,7 +1149,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1194,7 +1184,7 @@ def regenerate_primary_key( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1217,7 +1207,6 @@ def regenerate_primary_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1253,7 +1242,7 @@ def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1276,7 +1265,6 @@ def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1312,7 +1300,7 @@ def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1335,7 +1323,6 @@ def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1353,7 +1340,7 @@ def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionKeysContract", pipeline_response) + deserialized = self._deserialize("SubscriptionKeysContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_api_link_operations.py new file mode 100644 index 000000000000..72d36e21e4c9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_api_link_operations.py @@ -0,0 +1,645 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + tag_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, tag_id: str, api_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, service_name: str, tag_id: str, api_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, service_name: str, tag_id: str, api_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class TagApiLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tag_api_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagApiLinkContract"]: + """Lists a collection of the API links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagApiLinkContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagApiLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TagApiLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, tag_id: str, api_link_id: str, **kwargs: Any + ) -> _models.TagApiLinkContract: + """Gets the API link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + api_link_id: str, + parameters: _models.TagApiLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + api_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + api_link_id: str, + parameters: Union[_models.TagApiLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Is either a TagApiLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract or IO[bytes] + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagApiLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, tag_id: str, api_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified API from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operation_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operation_link_operations.py new file mode 100644 index 000000000000..33d94094ca3b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operation_link_operations.py @@ -0,0 +1,661 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + tag_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationLinkId": _SERIALIZER.url( + "operation_link_id", operation_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationLinkId": _SERIALIZER.url( + "operation_link_id", operation_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationLinkId": _SERIALIZER.url( + "operation_link_id", operation_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class TagOperationLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tag_operation_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagOperationLinkContract"]: + """Lists a collection of the operation links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| operationId + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagOperationLinkContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagOperationLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TagOperationLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, tag_id: str, operation_link_id: str, **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Gets the operation link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagOperationLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + parameters: _models.TagOperationLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + parameters: Union[_models.TagOperationLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Is either a TagOperationLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract or IO[bytes] + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagOperationLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagOperationLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, tag_id: str, operation_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified operation from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py index 87c761434a1d..33391b741340 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +55,7 @@ def build_list_by_operation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +77,7 @@ def build_list_by_operation_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -106,7 +109,7 @@ def build_get_entity_state_by_operation_request( # pylint: disable=name-too-lon _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +132,7 @@ def build_get_entity_state_by_operation_request( # pylint: disable=name-too-lon "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -155,7 +158,7 @@ def build_get_by_operation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +181,7 @@ def build_get_by_operation_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -204,7 +207,7 @@ def build_assign_to_operation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,7 +230,7 @@ def build_assign_to_operation_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -253,7 +256,7 @@ def build_detach_from_operation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +279,7 @@ def build_detach_from_operation_request( "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -304,7 +307,7 @@ def build_list_by_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -325,7 +328,7 @@ def build_list_by_api_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -351,7 +354,7 @@ def build_get_entity_state_by_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -373,7 +376,7 @@ def build_get_entity_state_by_api_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -393,7 +396,7 @@ def build_get_by_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -415,7 +418,7 @@ def build_get_by_api_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -435,7 +438,7 @@ def build_assign_to_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -457,7 +460,7 @@ def build_assign_to_api_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -477,7 +480,7 @@ def build_detach_from_api_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -499,7 +502,7 @@ def build_detach_from_api_request( ), "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -527,7 +530,7 @@ def build_list_by_product_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -548,7 +551,7 @@ def build_list_by_product_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -574,7 +577,7 @@ def build_get_entity_state_by_product_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -596,7 +599,7 @@ def build_get_entity_state_by_product_request( # pylint: disable=name-too-long ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -616,7 +619,7 @@ def build_get_by_product_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -638,7 +641,7 @@ def build_get_by_product_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -658,7 +661,7 @@ def build_assign_to_product_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -680,7 +683,7 @@ def build_assign_to_product_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -700,7 +703,7 @@ def build_detach_from_product_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -722,7 +725,7 @@ def build_detach_from_product_request( ), "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -750,7 +753,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -770,7 +773,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -798,7 +801,7 @@ def build_get_entity_state_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -819,7 +822,7 @@ def build_get_entity_state_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -839,7 +842,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -860,7 +863,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -886,7 +889,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -908,7 +911,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -932,7 +935,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -954,7 +957,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -977,7 +980,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -998,7 +1001,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1077,7 +1080,7 @@ def list_by_operation( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1101,7 +1104,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1117,7 +1119,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1171,7 +1172,7 @@ def get_entity_state_by_operation( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1196,7 +1197,6 @@ def get_entity_state_by_operation( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1242,7 +1242,7 @@ def get_by_operation( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1267,7 +1267,6 @@ def get_by_operation( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1285,7 +1284,7 @@ def get_by_operation( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1316,7 +1315,7 @@ def assign_to_operation( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1341,7 +1340,6 @@ def assign_to_operation( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1356,11 +1354,7 @@ def assign_to_operation( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("TagContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1391,7 +1385,7 @@ def detach_from_operation( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1416,7 +1410,6 @@ def detach_from_operation( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1475,7 +1468,7 @@ def list_by_api( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1498,7 +1491,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1514,7 +1506,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1565,7 +1556,7 @@ def get_entity_state_by_api( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1589,7 +1580,6 @@ def get_entity_state_by_api( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1632,7 +1622,7 @@ def get_by_api( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1656,7 +1646,6 @@ def get_by_api( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1674,7 +1663,7 @@ def get_by_api( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1702,7 +1691,7 @@ def assign_to_api( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1726,7 +1715,6 @@ def assign_to_api( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1742,15 +1730,9 @@ def assign_to_api( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("TagContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1778,7 +1760,7 @@ def detach_from_api( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1802,7 +1784,6 @@ def detach_from_api( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1861,7 +1842,7 @@ def list_by_product( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1884,7 +1865,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1900,7 +1880,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1951,7 +1930,7 @@ def get_entity_state_by_product( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1975,7 +1954,6 @@ def get_entity_state_by_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2018,7 +1996,7 @@ def get_by_product( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2042,7 +2020,6 @@ def get_by_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2060,7 +2037,7 @@ def get_by_product( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2088,7 +2065,7 @@ def assign_to_product( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2112,7 +2089,6 @@ def assign_to_product( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2127,11 +2103,7 @@ def assign_to_product( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("TagContract", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2159,7 +2131,7 @@ def detach_from_product( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2183,7 +2155,6 @@ def detach_from_product( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2241,7 +2212,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2264,7 +2235,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -2280,7 +2250,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -2326,7 +2295,7 @@ def get_entity_state(self, resource_group_name: str, service_name: str, tag_id: :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2349,7 +2318,6 @@ def get_entity_state(self, resource_group_name: str, service_name: str, tag_id: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2387,7 +2355,7 @@ def get(self, resource_group_name: str, service_name: str, tag_id: str, **kwargs :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2410,7 +2378,6 @@ def get(self, resource_group_name: str, service_name: str, tag_id: str, **kwargs headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2428,7 +2395,7 @@ def get(self, resource_group_name: str, service_name: str, tag_id: str, **kwargs response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2535,7 +2502,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2571,7 +2538,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2587,15 +2553,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("TagContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2702,7 +2662,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2738,7 +2698,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -2756,7 +2715,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TagContract", pipeline_response) + deserialized = self._deserialize("TagContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2784,7 +2743,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2808,7 +2767,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_product_link_operations.py new file mode 100644 index 000000000000..00340b828cc6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_product_link_operations.py @@ -0,0 +1,646 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + tag_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, tag_id: str, product_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "productLinkId": _SERIALIZER.url( + "product_link_id", product_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, service_name: str, tag_id: str, product_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "productLinkId": _SERIALIZER.url( + "product_link_id", product_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, service_name: str, tag_id: str, product_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "productLinkId": _SERIALIZER.url( + "product_link_id", product_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class TagProductLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tag_product_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagProductLinkContract"]: + """Lists a collection of the product links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| productId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagProductLinkContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagProductLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TagProductLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, tag_id: str, product_link_id: str, **kwargs: Any + ) -> _models.TagProductLinkContract: + """Gets the product link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagProductLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + product_link_id: str, + parameters: _models.TagProductLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + product_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + product_link_id: str, + parameters: Union[_models.TagProductLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Is either a TagProductLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract or IO[bytes] + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagProductLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagProductLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, tag_id: str, product_link_id: str, **kwargs: Any + ) -> None: + """Deletes the specified product from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py index db5c4e3fe86c..885756913438 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +72,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -155,7 +158,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TagResourceCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,7 +180,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -193,7 +195,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py index 6c21a0eb1c00..53ec81cd9724 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +47,7 @@ def build_regenerate_primary_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +67,7 @@ def build_regenerate_primary_key_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "accessName": _SERIALIZER.url("access_name", access_name, "str"), } @@ -89,7 +92,7 @@ def build_regenerate_secondary_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +112,7 @@ def build_regenerate_secondary_key_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "accessName": _SERIALIZER.url("access_name", access_name, "str"), } @@ -161,7 +164,7 @@ def regenerate_primary_key( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -184,7 +187,6 @@ def regenerate_primary_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -220,7 +222,7 @@ def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -243,7 +245,6 @@ def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py index 19aaa7949e6b..f8471d269bb9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +46,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +66,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -89,7 +92,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +112,7 @@ def build_get_entity_tag_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "accessName": _SERIALIZER.url("access_name", access_name, "str"), } @@ -134,7 +137,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +157,7 @@ def build_get_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "accessName": _SERIALIZER.url("access_name", access_name, "str"), } @@ -181,7 +184,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +206,7 @@ def build_create_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "accessName": _SERIALIZER.url("access_name", access_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -232,7 +235,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -254,7 +257,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "accessName": _SERIALIZER.url("access_name", access_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -281,7 +284,7 @@ def build_regenerate_primary_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -301,7 +304,7 @@ def build_regenerate_primary_key_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "accessName": _SERIALIZER.url("access_name", access_name, "str"), } @@ -326,7 +329,7 @@ def build_regenerate_secondary_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +349,7 @@ def build_regenerate_secondary_key_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "accessName": _SERIALIZER.url("access_name", access_name, "str"), } @@ -371,7 +374,7 @@ def build_list_secrets_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -391,7 +394,7 @@ def build_list_secrets_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "accessName": _SERIALIZER.url("access_name", access_name, "str"), } @@ -450,7 +453,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AccessInformationCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,7 +473,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -486,7 +488,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -534,7 +535,7 @@ def get_entity_tag( :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -557,7 +558,6 @@ def get_entity_tag( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -597,7 +597,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -620,7 +620,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -638,7 +637,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AccessInformationContract", pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -746,7 +745,7 @@ def create( :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -782,7 +781,6 @@ def create( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -800,7 +798,7 @@ def create( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AccessInformationContract", pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -908,7 +906,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -944,7 +942,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -962,7 +959,7 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AccessInformationContract", pipeline_response) + deserialized = self._deserialize("AccessInformationContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -987,7 +984,7 @@ def regenerate_primary_key( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1010,7 +1007,6 @@ def regenerate_primary_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1046,7 +1042,7 @@ def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1069,7 +1065,6 @@ def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1105,7 +1100,7 @@ def list_secrets( :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1128,7 +1123,6 @@ def list_secrets( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1146,7 +1140,7 @@ def list_secrets( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("AccessInformationSecretsContract", pipeline_response) + deserialized = self._deserialize("AccessInformationSecretsContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py index 043a833ea5b1..7d13e52b249e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,8 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,7 @@ def build_deploy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -68,7 +73,7 @@ def build_deploy_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), } @@ -95,7 +100,7 @@ def build_save_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -116,7 +121,7 @@ def build_save_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), } @@ -143,7 +148,7 @@ def build_validate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -164,7 +169,7 @@ def build_validate_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), } @@ -191,7 +196,7 @@ def build_get_sync_state_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -211,7 +216,7 @@ def build_get_sync_state_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), } @@ -252,8 +257,8 @@ def _deploy_initial( configuration_name: Union[str, _models.ConfigurationIdName], parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationResultContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -266,7 +271,7 @@ def _deploy_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OperationResultContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -288,10 +293,10 @@ def _deploy_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -299,16 +304,22 @@ def _deploy_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationResultContract", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -440,10 +451,11 @@ def begin_deploy( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationResultContract", pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -474,8 +486,8 @@ def _save_initial( configuration_name: Union[str, _models.ConfigurationIdName], parameters: Union[_models.SaveConfigurationParameter, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationResultContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,7 +500,7 @@ def _save_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OperationResultContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -510,10 +522,10 @@ def _save_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -521,16 +533,22 @@ def _save_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationResultContract", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -662,10 +680,11 @@ def begin_save( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationResultContract", pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -696,8 +715,8 @@ def _validate_initial( configuration_name: Union[str, _models.ConfigurationIdName], parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationResultContract]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -710,7 +729,7 @@ def _validate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OperationResultContract]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -732,10 +751,10 @@ def _validate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -743,16 +762,22 @@ def _validate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("OperationResultContract", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -872,10 +897,11 @@ def begin_validate( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OperationResultContract", pipeline_response) + deserialized = self._deserialize("OperationResultContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -922,7 +948,7 @@ def get_sync_state( :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -945,7 +971,6 @@ def get_sync_state( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -960,7 +985,7 @@ def get_sync_state( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TenantConfigurationSyncStateContract", pipeline_response) + deserialized = self._deserialize("TenantConfigurationSyncStateContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py index b0ff8cb1e2d2..2596ef37b81a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +45,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +65,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -88,7 +91,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,7 +111,7 @@ def build_get_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "settingsType": _SERIALIZER.url("settings_type", settings_type, "str"), } @@ -166,7 +169,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TenantSettingsCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,7 +189,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -202,7 +204,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -253,7 +254,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -276,7 +277,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -294,7 +294,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("TenantSettingsContract", pipeline_response) + deserialized = self._deserialize("TenantSettingsContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py index a44daf3472b6..8360cedd5427 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +49,7 @@ def build_send_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +70,7 @@ def build_send_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -129,7 +132,7 @@ def send( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,7 +156,6 @@ def send( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py index 1a90bdf33d46..7abf620f73f1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -153,7 +156,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -176,7 +179,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -192,7 +194,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py index 2172465cd34d..5d71e5b54fff 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +45,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +66,7 @@ def build_list_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -121,7 +124,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UserIdentityCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -141,7 +144,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -157,7 +159,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py index b888ea9dfd3f..de0145250e7e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,20 +17,26 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +58,7 @@ def build_list_by_service_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +78,7 @@ def build_list_by_service_request( min_length=1, pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -99,7 +106,7 @@ def build_get_entity_tag_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +127,7 @@ def build_get_entity_tag_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -140,7 +147,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +168,7 @@ def build_get_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -188,7 +195,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -210,7 +217,7 @@ def build_create_or_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -236,7 +243,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -258,7 +265,7 @@ def build_update_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -290,7 +297,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -311,7 +318,7 @@ def build_delete_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -338,7 +345,7 @@ def build_generate_sso_url_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -359,7 +366,7 @@ def build_generate_sso_url_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -379,7 +386,7 @@ def build_get_shared_access_token_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -401,7 +408,7 @@ def build_get_shared_access_token_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -480,7 +487,7 @@ def list_by_service( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UserCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -503,7 +510,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -519,7 +525,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -565,7 +570,7 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, user_id: s :rtype: bool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,7 +593,6 @@ def get_entity_tag(self, resource_group_name: str, service_name: str, user_id: s headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -626,7 +630,7 @@ def get(self, resource_group_name: str, service_name: str, user_id: str, **kwarg :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -649,7 +653,6 @@ def get(self, resource_group_name: str, service_name: str, user_id: str, **kwarg headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -667,7 +670,7 @@ def get(self, resource_group_name: str, service_name: str, user_id: str, **kwarg response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("UserContract", pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -783,7 +786,7 @@ def create_or_update( :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -820,7 +823,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -836,15 +838,9 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("UserContract", pipeline_response) - - if response.status_code == 201: - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("UserContract", pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -951,7 +947,7 @@ def update( :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -987,7 +983,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1005,15 +1000,14 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("UserContract", pipeline_response) + deserialized = self._deserialize("UserContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, service_name: str, @@ -1023,34 +1017,8 @@ def delete( # pylint: disable=inconsistent-return-statements notify: Optional[bool] = None, app_type: Optional[Union[str, _models.AppType]] = None, **kwargs: Any - ) -> None: - """Deletes specific user. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param user_id: User identifier. Must be unique in the current API Management service instance. - Required. - :type user_id: str - :param if_match: ETag of the Entity. ETag should match the current entity state from the header - response of the GET request or it should be * for unconditional update. Required. - :type if_match: str - :param delete_subscriptions: Whether to delete user's subscription or not. Default value is - None. - :type delete_subscriptions: bool - :param notify: Send an Account Closed Email notification to the User. Default value is None. - :type notify: bool - :param app_type: Determines the type of application which send the create user request. Default - is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is - None. - :type app_type: str or ~azure.mgmt.apimanagement.models.AppType - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1062,7 +1030,7 @@ def delete( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -1077,23 +1045,123 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + service_name: str, + user_id: str, + if_match: str, + delete_subscriptions: Optional[bool] = None, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes specific user. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param delete_subscriptions: Whether to delete user's subscription or not. Default value is + None. + :type delete_subscriptions: bool + :param notify: Send an Account Closed Email notification to the User. Default value is None. + :type notify: bool + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + if_match=if_match, + delete_subscriptions=delete_subscriptions, + notify=notify, + app_type=app_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def generate_sso_url( @@ -1114,7 +1182,7 @@ def generate_sso_url( :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1137,7 +1205,6 @@ def generate_sso_url( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1152,7 +1219,7 @@ def generate_sso_url( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GenerateSsoUrlResult", pipeline_response) + deserialized = self._deserialize("GenerateSsoUrlResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1247,7 +1314,7 @@ def get_shared_access_token( :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1282,7 +1349,6 @@ def get_shared_access_token( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1297,7 +1363,7 @@ def get_shared_access_token( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("UserTokenResult", pipeline_response) + deserialized = self._deserialize("UserTokenResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py index f991e90bcbe6..9e87f0ef1096 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import ApiManagementClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +53,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +74,7 @@ def build_list_request( pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -97,7 +100,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +122,7 @@ def build_get_request( ), "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -199,7 +202,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -222,7 +225,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -238,7 +240,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -289,7 +290,7 @@ def get( :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -313,7 +314,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -331,7 +331,7 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("SubscriptionContract", pipeline_response) + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_diagnostic_operations.py new file mode 100644 index 000000000000..fb4c3c394ab3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_diagnostic_operations.py @@ -0,0 +1,1116 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_workspace_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiDiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_diagnostic` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.DiagnosticContract"]: + """Lists all diagnostics of an API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either DiagnosticContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DiagnosticCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiagnosticCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + **kwargs: Any + ) -> _models.DiagnosticContract: + """Gets the details of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic for an API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic for an API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic for an API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Is either a DiagnosticContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + if_match: str, + parameters: _models.DiagnosticUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + if_match: str, + parameters: Union[_models.DiagnosticUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Is either a DiagnosticUpdateContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract or IO[bytes] + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified Diagnostic from an API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_export_operations.py new file mode 100644 index 000000000000..c699b9f6fe69 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_export_operations.py @@ -0,0 +1,193 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + format: Union[str, _models.ExportFormat], + export: Union[str, _models.ExportApi], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["export"] = _SERIALIZER.query("export", export, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_export` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + format: Union[str, _models.ExportFormat], + export: Union[str, _models.ExportApi], + **kwargs: Any + ) -> _models.ApiExportResult: + """Gets the details of the API specified by its identifier in the format specified to the Storage + Blob with SAS Key valid for 5 minutes. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param format: Format in which to export the Api Details to the Storage Blob with Sas Key valid + for 5 minutes. Known values are: "swagger-link", "wsdl-link", "wadl-link", "openapi-link", and + "openapi+json-link". Required. + :type format: str or ~azure.mgmt.apimanagement.models.ExportFormat + :param export: Query parameter required to export the API details. "true" Required. + :type export: str or ~azure.mgmt.apimanagement.models.ExportApi + :return: ApiExportResult or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiExportResult] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + format=format, + export=export, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiExportResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_operations.py new file mode 100644 index 000000000000..20c2c9e26494 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_operations.py @@ -0,0 +1,1117 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_api_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiOperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_operation` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.OperationContract"]: + """Lists a collection of the operations for the specified API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param tags: Include tags in the response. Default value is None. + :type tags: str + :return: An iterator like instance of either OperationContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OperationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + tags=tags, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API operation specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + **kwargs: Any + ) -> _models.OperationContract: + """Gets the details of the API Operation specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + parameters: _models.OperationContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OperationContract: + """Creates a new operation in the API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OperationContract: + """Creates a new operation in the API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + parameters: Union[_models.OperationContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.OperationContract: + """Creates a new operation in the API or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param parameters: Create parameters. Is either a OperationContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OperationContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + if_match: str, + parameters: _models.OperationUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OperationContract: + """Updates the details of the operation in the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Operation Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OperationContract: + """Updates the details of the operation in the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Operation Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + if_match: str, + parameters: Union[_models.OperationUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.OperationContract: + """Updates the details of the operation in the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Operation Update parameters. Is either a OperationUpdateContract type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract or IO[bytes] + :return: OperationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "OperationUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("OperationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified operation in the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_policy_operations.py new file mode 100644 index 000000000000..630beecd061e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_policy_operations.py @@ -0,0 +1,884 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_operation_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if format is not None: + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str", max_length=80, min_length=1), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiOperationPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_operation_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_operation( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + **kwargs: Any + ) -> Iterable["_models.PolicyContract"]: + """Get the list of policy configuration at the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API operation policy specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API Operation level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Is either a PolicyContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the Api Operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. Required. + :type operation_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operations.py new file mode 100644 index 000000000000..3dd5bed881c1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operations.py @@ -0,0 +1,1146 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + expand_api_version_set: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "str") + if expand_api_version_set is not None: + _params["expandApiVersionSet"] = _SERIALIZER.query("expand_api_version_set", expand_api_version_set, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + if_match: str, + delete_revisions: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if delete_revisions is not None: + _params["deleteRevisions"] = _SERIALIZER.query("delete_revisions", delete_revisions, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + expand_api_version_set: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.ApiContract"]: + """Lists all APIs of the workspace in an API Management service instance. + + .. seealso:: + - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-create-apis + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| isCurrent | filter | eq, ne | |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param tags: Include tags in the response. Default value is None. + :type tags: str + :param expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. + :type expand_api_version_set: bool + :return: An iterator like instance of either ApiContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + tags=tags, + expand_api_version_set=expand_api_version_set, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, **kwargs: Any + ) -> _models.ApiContract: + """Gets the details of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiCreateOrUpdateParameter") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: _models.ApiCreateOrUpdateParameter, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiContract]: + """Creates new or updates existing specified API of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ApiContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiContract]: + """Creates new or updates existing specified API of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ApiContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.ApiContract]: + """Creates new or updates existing specified API of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param parameters: Create or update parameters. Is either a ApiCreateOrUpdateParameter type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either ApiContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + if_match: str, + parameters: _models.ApiUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates the specified API of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Update Contract parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates the specified API of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Update Contract parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + if_match: str, + parameters: Union[_models.ApiUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.ApiContract: + """Updates the specified API of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Update Contract parameters. Is either a ApiUpdateContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract or IO[bytes] + :return: ApiContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + if_match: str, + delete_revisions: Optional[bool] = None, + **kwargs: Any + ) -> None: + """Deletes the specified API of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param delete_revisions: Delete all revisions of the Api. Default value is None. + :type delete_revisions: bool + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_revisions=delete_revisions, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_policy_operations.py new file mode 100644 index 000000000000..c1d09c83cc69 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_policy_operations.py @@ -0,0 +1,831 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_api_request( + resource_group_name: str, service_name: str, workspace_id: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if format is not None: + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, **kwargs: Any + ) -> Iterable["_models.PolicyContract"]: + """Get the policy configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API policy specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Is either a PolicyContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the Api. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_release_operations.py new file mode 100644 index 000000000000..8e81f005bba9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_release_operations.py @@ -0,0 +1,1118 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "releaseId": _SERIALIZER.url( + "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "releaseId": _SERIALIZER.url( + "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "releaseId": _SERIALIZER.url( + "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "releaseId": _SERIALIZER.url( + "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "releaseId": _SERIALIZER.url( + "release_id", release_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiReleaseOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_release` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApiReleaseContract"]: + """Lists all releases of an API. An API release is created when making an API Revision current. + Releases are also used to rollback to previous revisions. Results will be paged and can be + constrained by the $top and $skip parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| notes | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ApiReleaseContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiReleaseCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiReleaseCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + **kwargs: Any + ) -> bool: + """Returns the etag of an API release. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Returns the details of an API release. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + parameters: _models.ApiReleaseContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Creates a new Release for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Creates a new Release for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + parameters: Union[_models.ApiReleaseContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Creates a new Release for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param parameters: Create parameters. Is either a ApiReleaseContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiReleaseContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + if_match: str, + parameters: _models.ApiReleaseContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Updates the details of the release of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Release Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Updates the details of the release of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Release Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + if_match: str, + parameters: Union[_models.ApiReleaseContract, IO[bytes]], + **kwargs: Any + ) -> _models.ApiReleaseContract: + """Updates the details of the release of the API specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: API Release Update parameters. Is either a ApiReleaseContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or IO[bytes] + :return: ApiReleaseContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiReleaseContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiReleaseContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified release in the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. Required. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_revision_operations.py new file mode 100644 index 000000000000..97fd05aa2e10 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_revision_operations.py @@ -0,0 +1,230 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/revisions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_revision` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApiRevisionContract"]: + """Lists all revisions of an API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiRevision + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ApiRevisionContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiRevisionCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiRevisionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_schema_operations.py new file mode 100644 index 000000000000..0c333452024d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_schema_operations.py @@ -0,0 +1,947 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_api_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + subscription_id: str, + *, + if_match: str, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_schema` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SchemaContract"]: + """Get the schema configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| contentType + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either SchemaContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SchemaCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SchemaCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, schema_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the schema specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, schema_id: str, **kwargs: Any + ) -> _models.SchemaContract: + """Get the schema configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: SchemaContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SchemaContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SchemaContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + parameters: Union[_models.SchemaContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SchemaContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + parameters: _models.SchemaContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SchemaContract]: + """Creates or updates schema configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: The schema contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SchemaContract]: + """Creates or updates schema configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: The schema contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + parameters: Union[_models.SchemaContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.SchemaContract]: + """Creates or updates schema configuration for the API. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: The schema contents to apply. Is either a SchemaContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either SchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SchemaContract] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("SchemaContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SchemaContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SchemaContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + if_match: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + """Deletes the schema configuration at the Api. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param force: If true removes all references to the schema before deleting it. Default value is + None. + :type force: bool + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + force=force, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_version_set_operations.py new file mode 100644 index 000000000000..96fbf49c5a8b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_version_set_operations.py @@ -0,0 +1,1048 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "versionSetId": _SERIALIZER.url( + "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "versionSetId": _SERIALIZER.url( + "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "versionSetId": _SERIALIZER.url( + "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "versionSetId": _SERIALIZER.url( + "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "versionSetId": _SERIALIZER.url( + "version_set_id", version_set_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceApiVersionSetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_api_version_set` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApiVersionSetContract"]: + """Lists a collection of API Version Sets in the specified workspace with a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ApiVersionSetContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiVersionSetCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiVersionSetCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, version_set_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Api Version Set specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, version_set_id: str, **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Gets the details of the Api Version Set specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + parameters: _models.ApiVersionSetContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Creates or Updates a Api Version Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Creates or Updates a Api Version Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + parameters: Union[_models.ApiVersionSetContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Creates or Updates a Api Version Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param parameters: Create or update parameters. Is either a ApiVersionSetContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiVersionSetContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + if_match: str, + parameters: _models.ApiVersionSetUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Updates the details of the Api VersionSet specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Updates the details of the Api VersionSet specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + if_match: str, + parameters: Union[_models.ApiVersionSetUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ApiVersionSetContract: + """Updates the details of the Api VersionSet specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a ApiVersionSetUpdateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters or IO[bytes] + :return: ApiVersionSetContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ApiVersionSetUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ApiVersionSetContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific Api Version Set. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_backend_operations.py new file mode 100644 index 000000000000..ad833feebed7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_backend_operations.py @@ -0,0 +1,1030 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_workspace_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, backend_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, backend_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceBackendOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_backend` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.BackendContract"]: + """Lists a collection of backends in the specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| url | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either BackendContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.BackendContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackendCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BackendCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, backend_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the backend specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, backend_id: str, **kwargs: Any + ) -> _models.BackendContract: + """Gets the details of the backend specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + parameters: _models.BackendContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Creates or Updates a backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Creates or Updates a backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + parameters: Union[_models.BackendContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.BackendContract: + """Creates or Updates a backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Create parameters. Is either a BackendContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackendContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + if_match: str, + parameters: _models.BackendUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Updates an existing backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BackendContract: + """Updates an existing backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + if_match: str, + parameters: Union[_models.BackendUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.BackendContract: + """Updates an existing backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a BackendUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters or IO[bytes] + :return: BackendContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BackendUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("BackendContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified backend. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_certificate_operations.py new file mode 100644 index 000000000000..cb29537953b2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_certificate_operations.py @@ -0,0 +1,967 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_workspace_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + if is_key_vault_refresh_failed is not None: + _params["isKeyVaultRefreshFailed"] = _SERIALIZER.query( + "is_key_vault_refresh_failed", is_key_vault_refresh_failed, "bool" + ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "certificateId": _SERIALIZER.url( + "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "certificateId": _SERIALIZER.url( + "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "certificateId": _SERIALIZER.url( + "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "certificateId": _SERIALIZER.url( + "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_refresh_secret_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}/refreshSecret", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "certificateId": _SERIALIZER.url( + "certificate_id", certificate_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceCertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_certificate` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.CertificateContract"]: + """Lists a collection of all certificates in the specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| subject | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + thumbprint | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param is_key_vault_refresh_failed: When set to true, the response contains only certificates + entities which failed refresh. Default value is None. + :type is_key_vault_refresh_failed: bool + :return: An iterator like instance of either CertificateContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.CertificateContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + is_key_vault_refresh_failed=is_key_vault_refresh_failed, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CertificateCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, certificate_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the certificate specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, certificate_id: str, **kwargs: Any + ) -> _models.CertificateContract: + """Gets the details of the certificate specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + parameters: _models.CertificateCreateOrUpdateParameters, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the backend. + + .. seealso:: + - + https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-mutual-certificates/ + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Create or Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the backend. + + .. seealso:: + - + https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-mutual-certificates/ + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Create or Update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the backend. + + .. seealso:: + - + https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-mutual-certificates/ + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Create or Update parameters. Is either a CertificateCreateOrUpdateParameters + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters or + IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CertificateCreateOrUpdateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def refresh_secret( + self, resource_group_name: str, service_name: str, workspace_id: str, certificate_id: str, **kwargs: Any + ) -> _models.CertificateContract: + """From KeyVault, Refresh the certificate being used for authentication with the backend. + + .. seealso:: + - + https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-mutual-certificates/ + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: CertificateContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("CertificateContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_diagnostic_operations.py new file mode 100644 index 000000000000..10bea931ded7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_diagnostic_operations.py @@ -0,0 +1,1048 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_workspace_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "diagnosticId": _SERIALIZER.url( + "diagnostic_id", diagnostic_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceDiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_diagnostic` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.DiagnosticContract"]: + """Lists all diagnostics in the specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either DiagnosticContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DiagnosticCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiagnosticCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, diagnostic_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, diagnostic_id: str, **kwargs: Any + ) -> _models.DiagnosticContract: + """Gets the details of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.DiagnosticContract: + """Creates a new Diagnostic or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Is either a DiagnosticContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + if_match: str, + parameters: _models.DiagnosticUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + if_match: str, + parameters: Union[_models.DiagnosticUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.DiagnosticContract: + """Updates the details of the Diagnostic specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Diagnostic Update parameters. Is either a DiagnosticUpdateContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract or IO[bytes] + :return: DiagnosticContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("DiagnosticContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified Diagnostic. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_global_schema_operations.py new file mode 100644 index 000000000000..6e5fd662bc15 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_global_schema_operations.py @@ -0,0 +1,890 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, schema_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, schema_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceGlobalSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_global_schema` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GlobalSchemaContract"]: + """Lists a collection of schemas registered with workspace in a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either GlobalSchemaContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalSchemaCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GlobalSchemaCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, schema_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Schema specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, schema_id: str, **kwargs: Any + ) -> _models.GlobalSchemaContract: + """Gets the details of the Schema specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: GlobalSchemaContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GlobalSchemaContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GlobalSchemaContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: _models.GlobalSchemaContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either GlobalSchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either GlobalSchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param parameters: Create or update parameters. Is either a GlobalSchemaContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either GlobalSchemaContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GlobalSchemaContract] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("GlobalSchemaContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.GlobalSchemaContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.GlobalSchemaContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific Schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_operations.py new file mode 100644 index 000000000000..547f1d107007 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_operations.py @@ -0,0 +1,1033 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_group` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GroupContract"]: + """Lists a collection of groups defined within a workspace in a service instance. + + .. seealso:: + - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-create-groups + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| externalId | filter | eq | |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either GroupContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GroupCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GroupCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, **kwargs: Any + ) -> _models.GroupContract: + """Gets the details of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + parameters: _models.GroupCreateParameters, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GroupContract: + """Creates or Updates a group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GroupContract: + """Creates or Updates a group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + parameters: Union[_models.GroupCreateParameters, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.GroupContract: + """Creates or Updates a group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Create parameters. Is either a GroupCreateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GroupCreateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + if_match: str, + parameters: _models.GroupUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GroupContract: + """Updates the details of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GroupContract: + """Updates the details of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + if_match: str, + parameters: Union[_models.GroupUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.GroupContract: + """Updates the details of the group specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a GroupUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters or IO[bytes] + :return: GroupContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GroupUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("GroupContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific group of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_user_operations.py new file mode 100644 index 000000000000..f422c5b63bef --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_user_operations.py @@ -0,0 +1,590 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_entity_exists_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "groupId": _SERIALIZER.url("group_id", group_id, "str", max_length=256, min_length=1), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceGroupUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_group_user` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.UserContract"]: + """Lists a collection of user entities associated with the group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| firstName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, + le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either UserContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UserCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UserCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def check_entity_exists( + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, user_id: str, **kwargs: Any + ) -> bool: + """Checks that user entity specified by identifier is associated with the group entity. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def create( + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, user_id: str, **kwargs: Any + ) -> _models.UserContract: + """Add existing user to existing group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: UserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + _request = build_create_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UserContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, group_id: str, user_id: str, **kwargs: Any + ) -> None: + """Remove existing user from existing group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_logger_operations.py new file mode 100644 index 000000000000..d78cd89293fb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_logger_operations.py @@ -0,0 +1,1033 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_workspace_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, logger_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, logger_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceLoggerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_logger` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_workspace( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.LoggerContract"]: + """Lists a collection of loggers in the specified workspace. + + .. seealso:: + - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-log-event-hubs + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| loggerType | filter | eq | |
| resourceId | filter | ge, le, eq, ne, gt, lt | + substringof, contains, startswith, endswith |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either LoggerContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.LoggerContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LoggerCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_workspace_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LoggerCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, logger_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the logger specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, logger_id: str, **kwargs: Any + ) -> _models.LoggerContract: + """Gets the details of the logger specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + parameters: _models.LoggerContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Creates or Updates a logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Creates or Updates a logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + parameters: Union[_models.LoggerContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.LoggerContract: + """Creates or Updates a logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Create parameters. Is either a LoggerContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LoggerContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + if_match: str, + parameters: _models.LoggerUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Updates an existing logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LoggerContract: + """Updates an existing logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + if_match: str, + parameters: Union[_models.LoggerUpdateContract, IO[bytes]], + **kwargs: Any + ) -> _models.LoggerContract: + """Updates an existing logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a LoggerUpdateContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract or IO[bytes] + :return: LoggerContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LoggerUpdateContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LoggerContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the specified logger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_named_value_operations.py new file mode 100644 index 000000000000..3fef03a9f3ba --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_named_value_operations.py @@ -0,0 +1,1526 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[Union[str, _models.KeyVaultRefreshState]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + if is_key_vault_refresh_failed is not None: + _params["isKeyVaultRefreshFailed"] = _SERIALIZER.query( + "is_key_vault_refresh_failed", is_key_vault_refresh_failed, "str" + ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_value_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}/listValue", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_refresh_secret_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}/refreshSecret", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "namedValueId": _SERIALIZER.url( + "named_value_id", named_value_id, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceNamedValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_named_value` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[Union[str, _models.KeyVaultRefreshState]] = None, + **kwargs: Any + ) -> Iterable["_models.NamedValueContract"]: + """Lists a collection of named values defined within a workspace in a service instance. + + .. seealso:: + - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-properties + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| tags | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith, any, all |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param is_key_vault_refresh_failed: Query parameter to fetch named value entities based on + refresh status. Known values are: "true" and "false". Default value is None. + :type is_key_vault_refresh_failed: str or ~azure.mgmt.apimanagement.models.KeyVaultRefreshState + :return: An iterator like instance of either NamedValueContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamedValueCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + is_key_vault_refresh_failed=is_key_vault_refresh_failed, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NamedValueCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> _models.NamedValueContract: + """Gets the details of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: NamedValueContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamedValueCreateContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: _models.NamedValueCreateContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NamedValueContract]: + """Creates or updates named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NamedValueContract]: + """Creates or updates named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.NamedValueContract]: + """Creates or updates named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Is either a NamedValueCreateContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.NamedValueContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.NamedValueContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + parameters: Union[_models.NamedValueUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamedValueUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + parameters: _models.NamedValueUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NamedValueContract]: + """Updates the specific named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NamedValueContract]: + """Updates the specific named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + parameters: Union[_models.NamedValueUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.NamedValueContract]: + """Updates the specific named value. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a NamedValueUpdateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters or IO[bytes] + :return: An instance of LROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + if_match=if_match, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.NamedValueContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.NamedValueContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific named value from the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_value( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> _models.NamedValueSecretContract: + """Gets the secret of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: NamedValueSecretContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamedValueSecretContract] = kwargs.pop("cls", None) + + _request = build_list_value_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueSecretContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _refresh_secret_initial( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_refresh_secret( + self, resource_group_name: str, service_name: str, workspace_id: str, named_value_id: str, **kwargs: Any + ) -> LROPoller[_models.NamedValueContract]: + """Refresh the secret of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: An instance of LROPoller that returns either NamedValueContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._refresh_secret_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + named_value_id=named_value_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("NamedValueContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.NamedValueContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.NamedValueContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_operations.py new file mode 100644 index 000000000000..0f389deddb09 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_operations.py @@ -0,0 +1,467 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceNotificationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_notification` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.NotificationContract"]: + """Lists a collection of properties defined within a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either NotificationContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NotificationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NotificationCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + **kwargs: Any + ) -> _models.NotificationContract: + """Gets the details of the Notification specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :return: NotificationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NotificationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.NotificationContract: + """Create or Update API Management publisher notification for the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: NotificationContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NotificationContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_email_operations.py new file mode 100644 index 000000000000..7ebd5205afc3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_email_operations.py @@ -0,0 +1,556 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_notification_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_entity_exists_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceNotificationRecipientEmailOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_notification_recipient_email` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_notification( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + **kwargs: Any + ) -> _models.RecipientEmailCollection: + """Gets the list of the Notification Recipient Emails subscribed to a notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :return: RecipientEmailCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecipientEmailCollection] = kwargs.pop("cls", None) + + _request = build_list_by_notification_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecipientEmailCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + **kwargs: Any + ) -> bool: + """Determine if Notification Recipient Email subscribed to the notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param email: Email identifier. Required. + :type email: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + **kwargs: Any + ) -> _models.RecipientEmailContract: + """Adds the Email address to the list of Recipients for the Notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param email: Email identifier. Required. + :type email: str + :return: RecipientEmailContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecipientEmailContract] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecipientEmailContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + **kwargs: Any + ) -> None: + """Removes the email from the list of Notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param email: Email identifier. Required. + :type email: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_user_operations.py new file mode 100644 index 000000000000..7efaff900355 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_user_operations.py @@ -0,0 +1,559 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_notification_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_entity_exists_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str", max_length=80, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceNotificationRecipientUserOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_notification_recipient_user` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_notification( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + **kwargs: Any + ) -> _models.RecipientUserCollection: + """Gets the list of the Notification Recipient User subscribed to the notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :return: RecipientUserCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecipientUserCollection] = kwargs.pop("cls", None) + + _request = build_list_by_notification_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecipientUserCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + **kwargs: Any + ) -> bool: + """Determine if the Notification Recipient User is subscribed to the notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + **kwargs: Any + ) -> _models.RecipientUserContract: + """Adds the API Management User to the list of Recipients for the Notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: RecipientUserContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RecipientUserContract] = kwargs.pop("cls", None) + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RecipientUserContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + **kwargs: Any + ) -> None: + """Removes the API Management user from the list of Notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param notification_name: Notification Name Identifier. Known values are: + "RequestPublisherNotificationMessage", "PurchasePublisherNotificationMessage", + "NewApplicationNotificationMessage", "BCC", "NewIssuePublisherNotificationMessage", + "AccountClosedPublisher", and "QuotaLimitApproachingPublisherNotificationMessage". Required. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName + :param user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_operations.py new file mode 100644 index 000000000000..420e43576bee --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_operations.py @@ -0,0 +1,966 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.WorkspaceContract"]: + """Lists all workspaces of the API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |

| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either WorkspaceContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.WorkspaceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.WorkspaceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("WorkspaceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> _models.WorkspaceContract: + """Gets the details of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.WorkspaceContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("WorkspaceContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + parameters: _models.WorkspaceContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceContract: + """Creates a new workspace or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceContract: + """Creates a new workspace or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + parameters: Union[_models.WorkspaceContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.WorkspaceContract: + """Creates a new workspace or updates an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param parameters: Create parameters. Is either a WorkspaceContract type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkspaceContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "WorkspaceContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("WorkspaceContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + if_match: str, + parameters: _models.WorkspaceContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceContract: + """Updates the details of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Workspace Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WorkspaceContract: + """Updates the details of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Workspace Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + if_match: str, + parameters: Union[_models.WorkspaceContract, IO[bytes]], + **kwargs: Any + ) -> _models.WorkspaceContract: + """Updates the details of the workspace specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Workspace Update parameters. Is either a WorkspaceContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract or IO[bytes] + :return: WorkspaceContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WorkspaceContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "WorkspaceContract") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("WorkspaceContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, if_match: str, **kwargs: Any + ) -> None: + """Deletes the specified workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_fragment_operations.py new file mode 100644 index 000000000000..f4345b6b87e4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_fragment_operations.py @@ -0,0 +1,1037 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + subscription_id: str, + *, + format: Optional[Union[str, _models.PolicyFragmentContentFormat]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if format is not None: + _params["format"] = _SERIALIZER.query("format", format, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_references_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + subscription_id: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}/listReferences", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "id": _SERIALIZER.url("id", id, "str", max_length=80, min_length=1, pattern=r"(^[\w]+$)|(^[\w][\w\-]+[\w]$)"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspacePolicyFragmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_policy_fragment` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.PolicyFragmentContract"]: + """Gets all policy fragments defined within a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter, orderBy | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| value | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param orderby: OData order by query option. Default value is None. + :type orderby: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either PolicyFragmentContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyFragmentCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyFragmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + format: Optional[Union[str, _models.PolicyFragmentContentFormat]] = None, + **kwargs: Any + ) -> _models.PolicyFragmentContract: + """Gets a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param format: Policy fragment content format. Known values are: "xml" and "rawxml". Default + value is None. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :return: PolicyFragmentContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyFragmentContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyFragmentContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: Union[_models.PolicyFragmentContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyFragmentContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: _models.PolicyFragmentContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PolicyFragmentContract]: + """Creates or updates a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either PolicyFragmentContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PolicyFragmentContract]: + """Creates or updates a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either PolicyFragmentContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: Union[_models.PolicyFragmentContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.PolicyFragmentContract]: + """Creates or updates a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Is either a PolicyFragmentContract + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: An instance of LROPoller that returns either PolicyFragmentContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyFragmentContract] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PolicyFragmentContract", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PolicyFragmentContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PolicyFragmentContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, id: str, if_match: str, **kwargs: Any + ) -> None: + """Deletes a policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_references( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> _models.ResourceCollection: + """Lists policy resources that reference the policy fragment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param id: A resource identifier. Required. + :type id: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: ResourceCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ResourceCollection] = kwargs.pop("cls", None) + + _request = build_list_references_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ResourceCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_operations.py new file mode 100644 index 000000000000..98e19979978b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_operations.py @@ -0,0 +1,790 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_api_request( + resource_group_name: str, service_name: str, workspace_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if format is not None: + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspacePolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> Iterable["_models.PolicyContract"]: + """Get the policy configuration at the workspace level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :return: An iterator like instance of either PolicyContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the workspace policy specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the API level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Is either a PolicyContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_api_link_operations.py new file mode 100644 index 000000000000..43e8918c7d77 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_api_link_operations.py @@ -0,0 +1,715 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceProductApiLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_product_api_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ProductApiLinkContract"]: + """Lists a collection of the API links associated with a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ProductApiLinkContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductApiLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductApiLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Gets the API link for the product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + parameters: _models.ProductApiLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + parameters: Union[_models.ProductApiLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.ProductApiLinkContract: + """Adds an API to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Is either a ProductApiLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract or IO[bytes] + :return: ProductApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductApiLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProductApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified API from the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param api_link_id: Product-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_group_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_group_link_operations.py new file mode 100644 index 000000000000..345e44fdda95 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_group_link_operations.py @@ -0,0 +1,715 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "groupLinkId": _SERIALIZER.url( + "group_link_id", group_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "groupLinkId": _SERIALIZER.url( + "group_link_id", group_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "groupLinkId": _SERIALIZER.url( + "group_link_id", group_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceProductGroupLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_product_group_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ProductGroupLinkContract"]: + """Lists a collection of the group links associated with a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| groupId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either ProductGroupLinkContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductGroupLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductGroupLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Gets the group link for the product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductGroupLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + parameters: _models.ProductGroupLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + parameters: Union[_models.ProductGroupLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.ProductGroupLinkContract: + """Adds a group to the specified product via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :param parameters: Create or update parameters. Is either a ProductGroupLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract or IO[bytes] + :return: ProductGroupLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductGroupLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ProductGroupLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified group from the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_link_id: Product-Group link identifier. Must be unique in the current API + Management service instance. Required. + :type group_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + group_link_id=group_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_operations.py new file mode 100644 index 000000000000..c5e6a0a40ab9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_operations.py @@ -0,0 +1,1055 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + tags: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + if expand_groups is not None: + _params["expandGroups"] = _SERIALIZER.query("expand_groups", expand_groups, "bool") + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, product_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, product_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + subscription_id: str, + *, + if_match: str, + delete_subscriptions: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if delete_subscriptions is not None: + _params["deleteSubscriptions"] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_product` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ProductContract"]: + """Lists a collection of products in the specified workspace in a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | |
| groups | expand | | |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param expand_groups: When set to true, the response contains an array of groups that have + visibility to the product. The default is false. Default value is None. + :type expand_groups: bool + :param tags: Products which are part of a specific tag. Default value is None. + :type tags: str + :return: An iterator like instance of either ProductContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + expand_groups=expand_groups, + tags=tags, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ProductCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, product_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the product specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, product_id: str, **kwargs: Any + ) -> _models.ProductContract: + """Gets the details of the product specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + parameters: _models.ProductContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Creates or Updates a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Creates or Updates a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + parameters: Union[_models.ProductContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ProductContract: + """Creates or Updates a product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create or update parameters. Is either a ProductContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + if_match: str, + parameters: _models.ProductUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Update existing product details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ProductContract: + """Update existing product details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + if_match: str, + parameters: Union[_models.ProductUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.ProductContract: + """Update existing product details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a ProductUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters or IO[bytes] + :return: ProductContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ProductUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ProductContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + if_match: str, + delete_subscriptions: Optional[bool] = None, + **kwargs: Any + ) -> None: + """Delete product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param delete_subscriptions: Delete existing subscriptions associated with the product or not. + Default value is None. + :type delete_subscriptions: bool + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_subscriptions=delete_subscriptions, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_policy_operations.py new file mode 100644 index 000000000000..60c0e4ef46ce --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_policy_operations.py @@ -0,0 +1,803 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, service_name: str, workspace_id: str, product_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if format is not None: + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "productId": _SERIALIZER.url("product_id", product_id, "str", max_length=256, min_length=1), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceProductPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_product_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, resource_group_name: str, service_name: str, workspace_id: str, product_id: str, **kwargs: Any + ) -> _models.PolicyCollection: + """Get the policy configuration at the Product level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: PolicyCollection or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PolicyCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Get the ETag of the policy configuration at the Product level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + format: Union[str, _models.PolicyExportFormat] = "xml", + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the Product level. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the Product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the Product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the Product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param parameters: The policy contents to apply. Is either a PolicyContract type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: PolicyContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PolicyContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("PolicyContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + if_match: str, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the Product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_subscription_operations.py new file mode 100644 index 000000000000..875cc5ecbcd3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_subscription_operations.py @@ -0,0 +1,1446 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + subscription_id: str, + *, + notify: Optional[bool] = None, + if_match: Optional[str] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if notify is not None: + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if app_type is not None: + _params["appType"] = _SERIALIZER.query("app_type", app_type, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + subscription_id: str, + *, + if_match: str, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if notify is not None: + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if app_type is not None: + _params["appType"] = _SERIALIZER.query("app_type", app_type, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_primary_key_request( + resource_group_name: str, service_name: str, workspace_id: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/regeneratePrimaryKey", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_secondary_key_request( + resource_group_name: str, service_name: str, workspace_id: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/regenerateSecondaryKey", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_secrets_request( + resource_group_name: str, service_name: str, workspace_id: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/listSecrets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "sid": _SERIALIZER.url("sid", sid, "str", max_length=256, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceSubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_subscription` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SubscriptionContract"]: + """Lists all subscriptions of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| state | filter | eq | |
| user | expand | | + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either SubscriptionContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SubscriptionCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SubscriptionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the apimanagement subscription specified by its + identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> _models.SubscriptionContract: + """Gets the specified Subscription entity. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + parameters: _models.SubscriptionCreateParameters, + notify: Optional[bool] = None, + if_match: Optional[str] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionContract: + """Creates or updates the subscription of specified user to the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + parameters: IO[bytes], + notify: Optional[bool] = None, + if_match: Optional[str] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionContract: + """Creates or updates the subscription of specified user to the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + parameters: Union[_models.SubscriptionCreateParameters, IO[bytes]], + notify: Optional[bool] = None, + if_match: Optional[str] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> _models.SubscriptionContract: + """Creates or updates the subscription of specified user to the specified product. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Create parameters. Is either a SubscriptionCreateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters or IO[bytes] + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionCreateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + notify=notify, + if_match=if_match, + app_type=app_type, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + if_match: str, + parameters: _models.SubscriptionUpdateParameters, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionContract: + """Updates the details of a subscription specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + if_match: str, + parameters: IO[bytes], + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionContract: + """Updates the details of a subscription specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + if_match: str, + parameters: Union[_models.SubscriptionUpdateParameters, IO[bytes]], + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> _models.SubscriptionContract: + """Updates the details of a subscription specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a SubscriptionUpdateParameters type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters or IO[bytes] + :param notify: Notify change in Subscription State. + + + * If false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. Default value is None. + :type notify: bool + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. Known values are: "portal" and "developerPortal". Default value is + None. + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: SubscriptionContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + if_match=if_match, + notify=notify, + app_type=app_type, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, if_match: str, **kwargs: Any + ) -> None: + """Deletes the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def regenerate_primary_key( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> None: + """Regenerates primary key of existing subscription of the workspace in an API Management service + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_regenerate_primary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> None: + """Regenerates secondary key of existing subscription of the workspace in an API Management + service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_regenerate_secondary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_secrets( + self, resource_group_name: str, service_name: str, workspace_id: str, sid: str, **kwargs: Any + ) -> _models.SubscriptionKeysContract: + """Gets the specified Subscription keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionKeysContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SubscriptionKeysContract] = kwargs.pop("cls", None) + + _request = build_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("SubscriptionKeysContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_api_link_operations.py new file mode 100644 index 000000000000..3e6ea9594b0c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_api_link_operations.py @@ -0,0 +1,714 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "apiLinkId": _SERIALIZER.url( + "api_link_id", api_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceTagApiLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_tag_api_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagApiLinkContract"]: + """Lists a collection of the API links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagApiLinkContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagApiLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TagApiLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Gets the API link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + parameters: _models.TagApiLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + parameters: Union[_models.TagApiLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagApiLinkContract: + """Adds an API to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :param parameters: Create or update parameters. Is either a TagApiLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract or IO[bytes] + :return: TagApiLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagApiLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagApiLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified API from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param api_link_id: Tag-API link identifier. Must be unique in the current API Management + service instance. Required. + :type api_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + api_link_id=api_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operation_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operation_link_operations.py new file mode 100644 index 000000000000..51cb83bce0f0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operation_link_operations.py @@ -0,0 +1,715 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationLinkId": _SERIALIZER.url( + "operation_link_id", operation_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationLinkId": _SERIALIZER.url( + "operation_link_id", operation_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "operationLinkId": _SERIALIZER.url( + "operation_link_id", operation_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceTagOperationLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_tag_operation_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagOperationLinkContract"]: + """Lists a collection of the operation links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| operationId + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagOperationLinkContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagOperationLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TagOperationLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Gets the operation link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagOperationLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + parameters: _models.TagOperationLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + parameters: Union[_models.TagOperationLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagOperationLinkContract: + """Adds an operation to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :param parameters: Create or update parameters. Is either a TagOperationLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract or IO[bytes] + :return: TagOperationLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagOperationLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagOperationLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified operation from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param operation_link_id: Tag-operation link identifier. Must be unique in the current API + Management service instance. Required. + :type operation_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + operation_link_id=operation_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operations.py new file mode 100644 index 000000000000..361b91832fd0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operations.py @@ -0,0 +1,1030 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + scope: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + if scope is not None: + _params["scope"] = _SERIALIZER.query("scope", scope, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_entity_state_request( + resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceTagOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_tag` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + scope: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.TagContract"]: + """Lists a collection of tags defined within a workspace in a service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. + :type scope: str + :return: An iterator like instance of either TagContract or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + scope=scope, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TagCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_entity_state( + self, resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state version of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool or the result of cls(response) + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_entity_state_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Gets the details of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + parameters: _models.TagCreateUpdateParameters, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagContract: + """Creates a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + parameters: IO[bytes], + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagContract: + """Creates a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Create parameters. Required. + :type parameters: IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + parameters: Union[_models.TagCreateUpdateParameters, IO[bytes]], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.TagContract: + """Creates a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Create parameters. Is either a TagCreateUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or IO[bytes] + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagCreateUpdateParameters") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + if_match: str, + parameters: _models.TagCreateUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagContract: + """Updates the details of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + if_match: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagContract: + """Updates the details of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + if_match: str, + parameters: Union[_models.TagCreateUpdateParameters, IO[bytes]], + **kwargs: Any + ) -> _models.TagContract: + """Updates the details of the tag specified by its identifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :param parameters: Update parameters. Is either a TagCreateUpdateParameters type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or IO[bytes] + :return: TagContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagCreateUpdateParameters") + + _request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, if_match: str, **kwargs: Any + ) -> None: + """Deletes specific tag of the workspace in an API Management service instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. Required. + :type if_match: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_product_link_operations.py new file mode 100644 index 000000000000..be2dbb2505ed --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_product_link_operations.py @@ -0,0 +1,715 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=1) + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", minimum=0) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "productLinkId": _SERIALIZER.url( + "product_link_id", product_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "productLinkId": _SERIALIZER.url( + "product_link_id", product_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "workspaceId": _SERIALIZER.url( + "workspace_id", workspace_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + "productLinkId": _SERIALIZER.url( + "product_link_id", product_link_id, "str", max_length=80, min_length=1, pattern=r"^[^*#&+:<>?]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceTagProductLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`workspace_tag_product_link` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagProductLinkContract"]: + """Lists a collection of the product links associated with a tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| productId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :return: An iterator like instance of either TagProductLinkContract or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagProductLinkCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TagProductLinkCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Gets the product link for the tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("TagProductLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + parameters: _models.TagProductLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + parameters: Union[_models.TagProductLinkContract, IO[bytes]], + **kwargs: Any + ) -> _models.TagProductLinkContract: + """Adds a product to the specified tag via link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :param parameters: Create or update parameters. Is either a TagProductLinkContract type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract or IO[bytes] + :return: TagProductLinkContract or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagProductLinkContract") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TagProductLinkContract", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified product from the specified tag. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param workspace_id: Workspace identifier. Must be unique in the current API Management service + instance. Required. + :type workspace_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param product_link_id: Tag-product link identifier. Must be unique in the current API + Management service instance. Required. + :type product_link_id: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + tag_id=tag_id, + product_link_id=product_link_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_all_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_all_policies.py new file mode 100644 index 000000000000..c7a499725b5e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_all_policies.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_all_policies.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.all_policies.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementAllPolicies.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_apply_network_configuration_updates.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_apply_network_configuration_updates.py index 3dd87af23d74..efa75cd8ccd8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_apply_network_configuration_updates.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_apply_network_configuration_updates.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_apply_network_configuration_updates( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementApplyNetworkConfigurationUpdates.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementApplyNetworkConfigurationUpdates.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_approve_or_reject_private_endpoint_connection.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_approve_or_reject_private_endpoint_connection.py index 47ca9ebf4adc..b3ff94f49b9e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_approve_or_reject_private_endpoint_connection.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_approve_or_reject_private_endpoint_connection.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.private_endpoint_connection.begin_create_or_update( @@ -37,7 +35,7 @@ def main(): service_name="apimService1", private_endpoint_connection_name="privateEndpointConnectionName", private_endpoint_connection_request={ - "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/connectionName", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/connectionName", "properties": { "privateLinkServiceConnectionState": { "description": "The Private Endpoint Connection is approved.", @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementApproveOrRejectPrivateEndpointConnection.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementApproveOrRejectPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_authorization_server_list_secrets.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_authorization_server_list_secrets.py index 66aa19d8682e..32914d523413 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_authorization_server_list_secrets.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_authorization_server_list_secrets.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_server.list_secrets( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementAuthorizationServerListSecrets.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementAuthorizationServerListSecrets.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backend_reconnect.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backend_reconnect.py index 2dcfc0d108c7..0f3a74be9fee 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backend_reconnect.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backend_reconnect.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.backend.reconnect( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementBackendReconnect.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementBackendReconnect.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_access_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_access_key.py index 2a0e5cb7f855..85035b114cf9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_access_key.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_access_key.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_backup( @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementBackupWithAccessKey.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementBackupWithAccessKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_system_managed_identity.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_system_managed_identity.py index bed66ff2c560..796a7a89bd14 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_system_managed_identity.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_system_managed_identity.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_backup( @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementBackupWithSystemManagedIdentity.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementBackupWithSystemManagedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_user_assigned_managed_identity.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_user_assigned_managed_identity.py index c3217f2487a4..bbf6cd64743a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_user_assigned_managed_identity.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_backup_with_user_assigned_managed_identity.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_backup( @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementBackupWithUserAssignedManagedIdentity.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementBackupWithUserAssignedManagedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_ai_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_ai_logger.py index ebafe51242ac..90bdecdaaaf2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_ai_logger.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_ai_logger.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.logger.create_or_update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAILogger.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAILogger.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api.py index 795f6a7a9f36..4452b7951fe7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -53,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_clone.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_clone.py index 8ecf84be3b5f..46b3bb7a960b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_clone.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_clone.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -44,7 +42,7 @@ def main(): "path": "echo2", "protocols": ["http", "https"], "serviceUrl": "http://echoapi.cloudapp.net/api", - "sourceApiId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001", + "sourceApiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001", "subscriptionRequired": True, } }, @@ -52,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiClone.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiClone.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_diagnostic.py index 148ac7bb73e5..b3fd956b7ae6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_diagnostic.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_diagnostic.create_or_update( @@ -56,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue.py index 78a56e2e35bf..b2f4300e86da 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue.create_or_update( @@ -43,13 +41,13 @@ def main(): "description": "New API issue description", "state": "open", "title": "New API issue", - "userId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1", + "userId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1", } }, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiIssue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiIssue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue_attachment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue_attachment.py index 1d528b578d09..070dbcbad924 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue_attachment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue_attachment.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue_attachment.create_or_update( @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiIssueAttachment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiIssueAttachment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue_comment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue_comment.py index c5c99039fd71..4b6ed995130e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue_comment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_issue_comment.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue_comment.create_or_update( @@ -42,13 +40,13 @@ def main(): "properties": { "createdDate": "2018-02-01T22:21:20.467Z", "text": "Issue comment.", - "userId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1", + "userId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1", } }, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiIssueComment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiIssueComment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_new_version_using_existing_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_new_version_using_existing_api.py index 77914e3d2027..601e11ba61ed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_new_version_using_existing_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_new_version_using_existing_api.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -39,14 +37,14 @@ def main(): parameters={ "properties": { "apiVersion": "v4", - "apiVersionSetId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458", + "apiVersionSetId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458", "description": "Create Echo API into a new Version using Existing Version Set and Copy all Operations.", "displayName": "Echo API2", "isCurrent": True, "path": "echo2", "protocols": ["http", "https"], "serviceUrl": "http://echoapi.cloudapp.net/api", - "sourceApiId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath", + "sourceApiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath", "subscriptionRequired": True, } }, @@ -54,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiNewVersionUsingExistingApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiNewVersionUsingExistingApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation.py index 7137883ca85c..65cf5e02ecc3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation.create_or_update( @@ -66,6 +64,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiOperation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiOperation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation_policy.py index 97c283a58f4b..10ac7d5eef2f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation_policy.create_or_update( @@ -51,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiOperationPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiOperationPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation_tag.py index 0e47cfe4e3a0..f109d2c0389f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_operation_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.assign_to_operation( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiOperationTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiOperationTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_policy.py index 22bfabc0fc73..d33dec1d13c0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_policy.create_or_update( @@ -50,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_policy_non_xml_encoded.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_policy_non_xml_encoded.py index d10697303280..7b4f8415699c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_policy_non_xml_encoded.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_policy_non_xml_encoded.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_policy.create_or_update( @@ -50,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiPolicyNonXmlEncoded.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiPolicyNonXmlEncoded.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_release.py index c2b5ac57b9e2..c7ce0f1eb415 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_release.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_release.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_release.create_or_update( @@ -39,7 +37,7 @@ def main(): release_id="testrev", parameters={ "properties": { - "apiId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1", + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1", "notes": "yahooagain", } }, @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiRelease.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiRelease.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_revision_from_existing_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_revision_from_existing_api.py index 58df746c5359..09bc1d4dc617 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_revision_from_existing_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_revision_from_existing_api.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -41,13 +39,13 @@ def main(): "apiRevisionDescription": "Creating a Revision of an existing API", "path": "echo", "serviceUrl": "http://echoapi.cloudapp.net/apiv3", - "sourceApiId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", + "sourceApiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", } }, ).result() print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiRevisionFromExistingApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiRevisionFromExistingApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_schema.py index 29fe682f3055..d8727400326a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_schema.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_schema.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_schema.begin_create_or_update( @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiSchema.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiSchema.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tag.py index fbffafe62d06..7351e56fadf3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.assign_to_api( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tag_description.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tag_description.py index a53a6dc09db6..2bbfeccc422c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tag_description.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tag_description.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_tag_description.create_or_update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiTagDescription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiTagDescription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_import_override_service_url.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_import_override_service_url.py index 573cda6ddc9a..9dfaf4ee59d9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_import_override_service_url.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_import_override_service_url.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingImportOverrideServiceUrl.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiUsingImportOverrideServiceUrl.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_oai3_import.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_oai3_import.py index 9f7e66fca83c..1ac87224c1fc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_oai3_import.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_oai3_import.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingOai3Import.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiUsingOai3Import.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_oai3_import_with_translate_required_query_parameters_conduct.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_oai3_import_with_translate_required_query_parameters_conduct.py index 9247b88dc12f..4035cbc3093c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_oai3_import_with_translate_required_query_parameters_conduct.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_oai3_import_with_translate_required_query_parameters_conduct.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingOai3ImportWithTranslateRequiredQueryParametersConduct.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiUsingOai3ImportWithTranslateRequiredQueryParametersConduct.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_swagger_import.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_swagger_import.py index fd65860c4854..098c7844e183 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_swagger_import.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_swagger_import.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingSwaggerImport.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiUsingSwaggerImport.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_wadl_import.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_wadl_import.py index be5f77a74676..0bce78c1af97 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_wadl_import.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_using_wadl_import.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingWadlImport.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiUsingWadlImport.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_version_set.py index f264ccbe9e72..0787951f79bb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_version_set.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_version_set.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_version_set.create_or_update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiVersionSet.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiVersionSet.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_wiki.py index f75af9e56666..228befad2ba7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_wiki.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_wiki.create_or_update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_multiple_auth_servers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_multiple_auth_servers.py index f7aa7e312144..b11bb22982a5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_multiple_auth_servers.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_multiple_auth_servers.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -56,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiWithMultipleAuthServers.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiWithMultipleAuthServers.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_multiple_open_id_connect_providers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_multiple_open_id_connect_providers.py index 51baf16fb1fe..c5df1c7c565a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_multiple_open_id_connect_providers.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_multiple_open_id_connect_providers.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -62,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiWithMultipleOpenIdConnectProviders.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiWithMultipleOpenIdConnectProviders.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_open_id_connect.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_open_id_connect.py index 00ff26bb0787..346ce143ebcf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_open_id_connect.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_with_open_id_connect.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -53,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiWithOpenIdConnect.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateApiWithOpenIdConnect.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_aad_auth_code.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_aad_auth_code.py index c0e9c7775080..c9c335608652 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_aad_auth_code.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_aad_auth_code.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization.create_or_update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationAADAuthCode.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAuthorizationAADAuthCode.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_aad_client_cred.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_aad_client_cred.py index 136424336e69..94ec1ac3ec4d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_aad_client_cred.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_aad_client_cred.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization.create_or_update( @@ -41,16 +39,13 @@ def main(): "properties": { "authorizationType": "OAuth2", "oauth2grantType": "AuthorizationCode", - "parameters": { - "clientId": "53790925-fdd3-4b80-bc7a-4c3aaf25801d", - "clientSecret": "xxxxxxxxxxxxxxx~xxxxxxxxx", - }, + "parameters": {"clientId": "clientsecretid", "clientSecret": "clientsecretvalue"}, } }, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationAADClientCred.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAuthorizationAADClientCred.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_access_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_access_policy.py index e2ef181923a8..08700853ece4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_access_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_access_policy.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_access_policy.create_or_update( @@ -40,6 +38,7 @@ def main(): authorization_access_policy_id="fe0bed83-631f-4149-bd0b-0464b1bc7cab", parameters={ "properties": { + "appIds": ["d5f04bb0-ba78-4878-a43e-35a0b74fe315"], "objectId": "fe0bed83-631f-4149-bd0b-0464b1bc7cab", "tenantId": "13932a0d-5c63-4d37-901d-1df9c97722ff", } @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationAccessPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAuthorizationAccessPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_auth_code.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_auth_code.py index 5e207b22cc50..f1729731e70f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_auth_code.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_auth_code.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_provider.create_or_update( @@ -43,8 +41,8 @@ def main(): "oauth2": { "grantTypes": { "authorizationCode": { - "clientId": "59790825-fdd3-4b10-bc7a-4c3aaf25801d", - "clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxx", + "clientId": "clientsecretid", + "clientSecret": "clientsecretvalue", "resourceUri": "https://graph.microsoft.com", "scopes": "User.Read.All Group.Read.All", } @@ -57,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_client_cred.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_client_cred.py index 75087d593c76..7c1fde72ef9a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_client_cred.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_client_cred.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_provider.create_or_update( @@ -55,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_generic_oauth2.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_generic_oauth2.py index 300ff958185e..21668bcceaf8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_generic_oauth2.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_generic_oauth2.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_provider.create_or_update( @@ -44,10 +42,10 @@ def main(): "grantTypes": { "authorizationCode": { "authorizationUrl": "https://www.eventbrite.com/oauth/authorize", - "clientId": "genericClientId", - "clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxx", + "clientId": "clientid", + "clientSecret": "clientsecretvalue", "refreshUrl": "https://www.eventbrite.com/oauth/token", - "scopes": "", + "scopes": None, "tokenUrl": "https://www.eventbrite.com/oauth/token", } }, @@ -59,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_oob_google.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_oob_google.py index 5007f303c727..bea38dc7d74c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_oob_google.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_oob_google.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_provider.create_or_update( @@ -43,8 +41,8 @@ def main(): "oauth2": { "grantTypes": { "authorizationCode": { - "clientId": "99999999-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", - "clientSecret": "XXXXXXXXXXXXXXXXXXXX", + "clientId": "99999999-xxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", + "clientSecret": "clientsecretvalue", "scopes": "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email", } }, @@ -56,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_server.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_server.py index db604163bb16..29a3931101db 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_server.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_server.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_server.create_or_update( @@ -60,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationServer.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateAuthorizationServer.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_proxy_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_proxy_backend.py index 39eea9a2a057..15738497103b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_proxy_backend.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_proxy_backend.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.backend.create_or_update( @@ -54,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateBackendProxyBackend.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateBackendProxyBackend.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_service_fabric.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_service_fabric.py index 4b2dd41b87f0..85afa8f3db1f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_service_fabric.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_service_fabric.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.backend.create_or_update( @@ -41,7 +39,7 @@ def main(): "description": "Service Fabric Test App 1", "properties": { "serviceFabricCluster": { - "clientCertificateId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", + "clientCertificateId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", "managementEndpoints": ["https://somecluster.com"], "maxPartitionResolutionRetries": 5, "serverX509Names": [ @@ -57,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateBackendServiceFabric.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateBackendServiceFabric.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_cache.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_cache.py index 51734b97c986..fb3308db8724 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_cache.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_cache.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.cache.create_or_update( @@ -40,7 +38,7 @@ def main(): "properties": { "connectionString": "apim.redis.cache.windows.net:6380,password=xc,ssl=True,abortConnect=False", "description": "Redis cache instances in West India", - "resourceId": "https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1", + "resourceId": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1", "useFromLocation": "default", } }, @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateCache.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateCache.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_certificate.py index 3c4fc86ef3a3..8f074578fee3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_certificate.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_certificate.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.certificate.create_or_update( @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateCertificate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateCertificate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_certificate_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_certificate_with_key_vault.py index a62ba4b93a0d..9f8d61faa2c9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_certificate_with_key_vault.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_certificate_with_key_vault.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.certificate.create_or_update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateCertificateWithKeyVault.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateCertificateWithKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_content_type.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_content_type.py index 2f753eb79280..c6d9cf5bc10d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_content_type.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_content_type.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.content_type.create_or_update( @@ -88,6 +86,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateContentType.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateContentType.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_content_type_content_item.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_content_type_content_item.py index 42a5cd2f1691..a66b25209f55 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_content_type_content_item.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_content_type_content_item.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.content_item.create_or_update( @@ -52,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateContentTypeContentItem.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateContentTypeContentItem.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_diagnostic.py index 92bb01ecec29..73289d905e1f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_diagnostic.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.diagnostic.create_or_update( @@ -55,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_documentation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_documentation.py index 4058eddc8001..0bdeddf289e8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_documentation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_documentation.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.documentation.create_or_update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateDocumentation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateDocumentation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_eh_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_eh_logger.py index 018bab238e06..7115cd8e762e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_eh_logger.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_eh_logger.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.logger.create_or_update( @@ -50,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateEHLogger.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateEHLogger.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway.py index ce4bd494c43e..935aed8d7b46 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway.create_or_update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGateway.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGateway.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_api.py index da3fb7e85279..6eeeeeca5abe 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_api.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_api.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGatewayApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGatewayApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_certificate_authority.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_certificate_authority.py index 033b67a01dbc..2ff69707289e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_certificate_authority.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_certificate_authority.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_certificate_authority.create_or_update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGatewayCertificateAuthority.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGatewayCertificateAuthority.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_config_connection.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_config_connection.py new file mode 100644 index 000000000000..07607017005d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_config_connection.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_gateway_config_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway_config_connection.begin_create_or_update( + resource_group_name="rg1", + gateway_name="standard-gw-01", + config_connection_name="gcc-01", + parameters={ + "properties": { + "sourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/services/apim-service-1/workspaces/ws-001" + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGatewayConfigConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_hostname_configuration.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_hostname_configuration.py index eece8c385720..a2c0f36f7672 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_hostname_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_hostname_configuration.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_hostname_configuration.create_or_update( @@ -39,7 +37,7 @@ def main(): hc_id="default", parameters={ "properties": { - "certificateId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", + "certificateId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", "hostname": "*", "http2Enabled": True, "negotiateClientCertificate": False, @@ -51,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGatewayHostnameConfiguration.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGatewayHostnameConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_global_schema1.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_global_schema1.py index 1f7d05d80c1b..882c36701d1b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_global_schema1.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_global_schema1.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.global_schema.begin_create_or_update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGlobalSchema1.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGlobalSchema1.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_global_schema2.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_global_schema2.py index 96809f390c32..f84d1597d1d1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_global_schema2.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_global_schema2.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.global_schema.begin_create_or_update( @@ -61,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGlobalSchema2.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGlobalSchema2.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api.py index d214e403ae76..1d629ac21995 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -50,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGraphQLApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGraphQLApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api_resolver.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api_resolver.py index 49b10ccb4f89..39f5d8f087ee 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api_resolver.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api_resolver.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver.create_or_update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGraphQLApiResolver.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGraphQLApiResolver.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api_resolver_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api_resolver_policy.py index b27e995c94ce..4ac73d28466d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api_resolver_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_graph_ql_api_resolver_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver_policy.create_or_update( @@ -51,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGraphQLApiResolverPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGraphQLApiResolverPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group.py index 394831375be3..c72da2ef816d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group.create_or_update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group_external.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group_external.py index fa8592dfe0b7..fc2b07e98253 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group_external.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group_external.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group.create_or_update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGroupExternal.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGroupExternal.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group_user.py index e4d9d1725e86..6fae2a31f8ed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_group_user.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group_user.create( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGroupUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGroupUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_grpc_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_grpc_api.py new file mode 100644 index 000000000000..0be0171b038d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_grpc_api.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_grpc_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + api_id="tempgroup", + parameters={ + "properties": { + "description": "apidescription5200", + "displayName": "apiname1463", + "format": "grpc-link", + "path": "grpc-api", + "protocols": ["https"], + "serviceUrl": "https://your-api-hostname/samples", + "type": "grpc", + "value": "https://raw.githubusercontent.com/kedacore/keda/main/pkg/scalers/externalscaler/externalscaler.proto", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateGrpcApi.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_identity_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_identity_provider.py index 02fb426e3a99..a507158b2914 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_identity_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_identity_provider.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.identity_provider.create_or_update( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateIdentityProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateIdentityProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_multi_region_service_with_custom_hostname.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_multi_region_service_with_custom_hostname.py index 23a8c0811874..0c20da6b8dc0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_multi_region_service_with_custom_hostname.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_multi_region_service_with_custom_hostname.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -62,6 +60,12 @@ def main(): "hostName": "portal1.msitesting.net", "type": "Portal", }, + { + "certificatePassword": "Password", + "encodedCertificate": "****** Base 64 Encoded Certificate ************", + "hostName": "configuration-api.msitesting.net", + "type": "ConfigurationApi", + }, ], "publisherEmail": "apim@autorestsdk.com", "publisherName": "autorestsdk", @@ -74,6 +78,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateMultiRegionServiceWithCustomHostname.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateMultiRegionServiceWithCustomHostname.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_named_value.py index 25fbae15022b..b2885fd786d4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_named_value.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_named_value.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.begin_create_or_update( @@ -43,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNamedValue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateNamedValue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_named_value_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_named_value_with_key_vault.py index c75554f95b94..fba186de1c2d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_named_value_with_key_vault.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_named_value_with_key_vault.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.begin_create_or_update( @@ -51,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNamedValueWithKeyVault.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateNamedValueWithKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification.py index c4e43113a3dd..74964edcc647 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification.create_or_update( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNotification.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateNotification.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification_recipient_email.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification_recipient_email.py index e4eda87dd062..69dbfb82bd75 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification_recipient_email.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification_recipient_email.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification_recipient_email.create_or_update( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNotificationRecipientEmail.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateNotificationRecipientEmail.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification_recipient_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification_recipient_user.py index 42b92682dba5..a50c2298288a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification_recipient_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_notification_recipient_user.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification_recipient_user.create_or_update( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNotificationRecipientUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateNotificationRecipientUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_odata_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_odata_api.py new file mode 100644 index 000000000000..20126af047d1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_odata_api.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_odata_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + api_id="tempgroup", + parameters={ + "properties": { + "description": "apidescription5200", + "displayName": "apiname1463", + "format": "odata-link", + "path": "odata-api", + "protocols": ["http", "https"], + "serviceUrl": "https://services.odata.org/TripPinWebApiService", + "type": "odata", + "value": "https://services.odata.org/TripPinWebApiService/$metadata", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateODataApi.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_open_id_connect_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_open_id_connect_provider.py index 90ec5c3aa56d..74bcc8b37c52 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_open_id_connect_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_open_id_connect_provider.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.open_id_connect_provider.create_or_update( @@ -50,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateOpenIdConnectProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateOpenIdConnectProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy.py index 8b05fc576fd4..9a1165ecba73 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy.create_or_update( @@ -49,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreatePolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreatePolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy_fragment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy_fragment.py index dd9c1ea7e4d7..e0f84ed80ca4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy_fragment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy_fragment.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy_fragment.begin_create_or_update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreatePolicyFragment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreatePolicyFragment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy_restriction.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy_restriction.py new file mode 100644 index 000000000000..dfa68609fbcb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_policy_restriction.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_policy_restriction.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.policy_restriction.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + policy_restriction_id="policyRestriction1", + parameters={"properties": {"requireBase": "true", "scope": "Sample Path to the policy document."}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreatePolicyRestriction.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_portal_config.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_portal_config.py index b34cd16c6f33..a2a559307d24 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_portal_config.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_portal_config.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_config.create_or_update( @@ -62,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreatePortalConfig.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreatePortalConfig.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_portal_revision.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_portal_revision.py index f108ebed3134..e3bfe0d7c7c0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_portal_revision.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_portal_revision.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_revision.begin_create_or_update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreatePortalRevision.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreatePortalRevision.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product.py index 144d8a3dbde2..14c1ff625cb7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product.create_or_update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProduct.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateProduct.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_api.py index e9c7583d42ae..7867ed500e01 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_api.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_api.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateProductApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_api_link.py new file mode 100644 index 000000000000..32fc796529dd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_api_link.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_product_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.product_api_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + product_id="testproduct", + api_link_id="link1", + parameters={ + "properties": { + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateProductApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_group.py index 1713e706cb8d..a4f8b5fea723 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_group.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_group.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateProductGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_group_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_group_link.py new file mode 100644 index 000000000000..5bb040ed2cc6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_group_link.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_product_group_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.product_group_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + product_id="testproduct", + group_link_id="link1", + parameters={ + "properties": { + "groupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/group1" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateProductGroupLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_policy.py index 52bbc31e8a6e..7ab684ec40e9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_policy.create_or_update( @@ -50,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateProductPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_tag.py index 07ab1d31f2f6..250419264fc4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.assign_to_product( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateProductTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_wiki.py index 48a8254322a0..96fe08b05a8c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_product_wiki.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_wiki.create_or_update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateProductWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service.py index 988fb15918db..d5c1f31e711e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateService.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateService.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_having_msi.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_having_msi.py index 533d7cd1955e..726378abd4f9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_having_msi.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_having_msi.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceHavingMsi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceHavingMsi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_in_vnet_with_public_ip.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_in_vnet_with_public_ip.py index d51b010977a2..9e738ea6a612 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_in_vnet_with_public_ip.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_in_vnet_with_public_ip.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -38,11 +36,11 @@ def main(): parameters={ "location": "East US 2 EUAP", "properties": { - "publicIpAddressId": "/subscriptions/subid/resourceGroups/rgName/providers/Microsoft.Network/publicIPAddresses/apimazvnet", + "publicIpAddressId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.Network/publicIPAddresses/apimazvnet", "publisherEmail": "apim@autorestsdk.com", "publisherName": "autorestsdk", "virtualNetworkConfiguration": { - "subnetResourceId": "/subscriptions/subid/resourceGroups/rgName/providers/Microsoft.Network/virtualNetworks/apimcus/subnets/tenant" + "subnetResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.Network/virtualNetworks/apimcus/subnets/tenant" }, "virtualNetworkType": "External", }, @@ -54,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceInVnetWithPublicIP.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceInVnetWithPublicIP.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_in_zones.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_in_zones.py index 1b1b5135affe..1c9ea727f8f4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_in_zones.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_in_zones.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceInZones.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceInZones.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_skuv2_service.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_skuv2_service.py new file mode 100644 index 000000000000..3fd72652bf60 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_skuv2_service.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_service_skuv2_service.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_management_service.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + parameters={ + "identity": {"type": "SystemAssigned"}, + "location": "West US", + "properties": {"publisherEmail": "apim@autorestsdk.com", "publisherName": "autorestsdk"}, + "sku": {"capacity": 1, "name": "StandardV2"}, + "tags": {"tag1": "value1", "tag2": "value2", "tag3": "value3"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceSkuv2Service.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_custom_hostname_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_custom_hostname_key_vault.py index 4bb51386bf8e..130e3e361ce7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_custom_hostname_key_vault.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_custom_hostname_key_vault.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -39,7 +37,7 @@ def main(): "identity": { "type": "UserAssigned", "userAssignedIdentities": { - "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {} + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {} }, }, "location": "North Europe", @@ -65,6 +63,12 @@ def main(): "keyVaultId": "https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert", "type": "Portal", }, + { + "certificatePassword": "Password", + "encodedCertificate": "****** Base 64 Encoded Certificate ************", + "hostName": "configuration-api.msitesting.net", + "type": "ConfigurationApi", + }, ], "publisherEmail": "apim@autorestsdk.com", "publisherName": "autorestsdk", @@ -77,6 +81,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceWithCustomHostnameKeyVault.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceWithCustomHostnameKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_developer_portal.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_developer_portal.py new file mode 100644 index 000000000000..d4c2b29a2dd0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_developer_portal.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_service_with_developer_portal.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_management_service.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + parameters={ + "location": "South Central US", + "properties": { + "developerPortalStatus": "Enabled", + "publisherEmail": "foo@contoso.com", + "publisherName": "foo", + }, + "sku": {"capacity": 1, "name": "Developer"}, + "tags": {"Name": "Contoso", "Test": "User"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceWithDeveloperPortal.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_nat_gateway_enabled.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_nat_gateway_enabled.py index 1448415d9754..7625280670e6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_nat_gateway_enabled.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_nat_gateway_enabled.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceWithNatGatewayEnabled.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceWithNatGatewayEnabled.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_system_certificates.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_system_certificates.py index d63975a51d7e..c2626b8f3a27 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_system_certificates.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_system_certificates.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -55,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceWithSystemCertificates.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceWithSystemCertificates.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_user_assigned_identity.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_user_assigned_identity.py index 83f973b85a7a..aaa4102f1301 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_user_assigned_identity.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_with_user_assigned_identity.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -39,7 +37,7 @@ def main(): "identity": { "type": "UserAssigned", "userAssignedIdentities": { - "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/apimService1": {} + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/apimService1": {} }, }, "location": "West US", @@ -51,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceWithUserAssignedIdentity.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceWithUserAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_without_legacy_configuration_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_without_legacy_configuration_api.py new file mode 100644 index 000000000000..aa1cb5fac321 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_service_without_legacy_configuration_api.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_service_without_legacy_configuration_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_management_service.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + parameters={ + "location": "Central US", + "properties": { + "configurationApi": {"legacyApi": "Disabled"}, + "publisherEmail": "apim@autorestsdk.com", + "publisherName": "autorestsdk", + }, + "sku": {"capacity": 1, "name": "Basic"}, + "tags": {"tag1": "value1", "tag2": "value2", "tag3": "value3"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateServiceWithoutLegacyConfigurationApi.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_soap_pass_through_api_using_wsdl_import.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_soap_pass_through_api_using_wsdl_import.py index 251633f4860c..7a4e46bafe19 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_soap_pass_through_api_using_wsdl_import.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_soap_pass_through_api_using_wsdl_import.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateSoapPassThroughApiUsingWsdlImport.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateSoapPassThroughApiUsingWsdlImport.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_soap_to_rest_api_using_wsdl_import.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_soap_to_rest_api_using_wsdl_import.py index 7694e79ac435..26e8c26518f2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_soap_to_rest_api_using_wsdl_import.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_soap_to_rest_api_using_wsdl_import.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateSoapToRestApiUsingWsdlImport.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateSoapToRestApiUsingWsdlImport.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_standard_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_standard_gateway.py new file mode 100644 index 000000000000..6229bf021058 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_standard_gateway.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_standard_gateway.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway.begin_create_or_update( + resource_group_name="rg1", + gateway_name="apimGateway1", + parameters={ + "location": "South Central US", + "properties": { + "backend": { + "subnet": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vn1/subnets/sn1" + } + } + }, + "sku": {"capacity": 1, "name": "Standard"}, + "tags": {"Name": "Contoso", "Test": "User"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateStandardGateway.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_subscription.py index 92571e820f8b..a8526b49c87f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_subscription.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_subscription.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.subscription.create_or_update( @@ -39,14 +37,14 @@ def main(): parameters={ "properties": { "displayName": "testsub", - "ownerId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7", - "scope": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002", + "ownerId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7", + "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002", } }, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateSubscription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateSubscription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag.py index 25e575987f49..c3acdd45bc30 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.create_or_update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_api_link.py new file mode 100644 index 000000000000..13344a85e410 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_api_link.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_tag_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_api_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + api_link_id="link1", + parameters={ + "properties": { + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateTagApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_operation_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_operation_link.py new file mode 100644 index 000000000000..bc7d00f69fd9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_operation_link.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_tag_operation_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_operation_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + operation_link_id="link1", + parameters={ + "properties": { + "operationId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api/operations/op1" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateTagOperationLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_product_link.py new file mode 100644 index 000000000000..9bf93d00841f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tag_product_link.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_tag_product_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_product_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + product_link_id="link1", + parameters={ + "properties": { + "productId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/product1" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateTagProductLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_template.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_template.py index 6b2a883b22ce..fe075657b58a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_template.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_template.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.email_template.create_or_update( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateTemplate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateTemplate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tenant_access.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tenant_access.py index a2a4ed6d5c41..36e5aa1adaff 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tenant_access.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_tenant_access.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_access.create( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateTenantAccess.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateTenantAccess.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_user.py index c131f88e7621..50b99299fa14 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_user.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user.create_or_update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_websocket_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_websocket_api.py index a4d2d45e9c3a..51f002d85124 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_websocket_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_websocket_api.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.begin_create_or_update( @@ -50,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateWebsocketApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWebsocketApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace.py new file mode 100644 index 000000000000..eb0665df9a7a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + parameters={"properties": {"description": "workspace 1", "displayName": "my workspace"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspace.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_ai_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_ai_logger.py new file mode 100644 index 000000000000..cdd26bcefd91 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_ai_logger.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_ai_logger.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_logger.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + logger_id="loggerId", + parameters={ + "properties": { + "credentials": {"instrumentationKey": "11................a1"}, + "description": "adding a new logger", + "loggerType": "applicationInsights", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceAILogger.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api.py new file mode 100644 index 000000000000..6c7e1906705d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="tempgroup", + parameters={ + "properties": { + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "authorizationServerId2283", "scope": "oauth2scope2580"} + }, + "description": "apidescription5200", + "displayName": "apiname1463", + "path": "newapiPath", + "protocols": ["https", "http"], + "serviceUrl": "http://newechoapi.cloudapp.net/api", + "subscriptionKeyParameterNames": {"header": "header4520", "query": "query3037"}, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceApi.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_diagnostic.py new file mode 100644 index 000000000000..09864f23318a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_diagnostic.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_api_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_diagnostic.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d1f7558aa04f15146d9d8a", + diagnostic_id="applicationinsights", + parameters={ + "properties": { + "alwaysLog": "allErrors", + "backend": { + "request": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + "response": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + }, + "frontend": { + "request": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + "response": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + }, + "loggerId": "/workspaces/wks1/loggers/applicationinsights", + "sampling": {"percentage": 50, "samplingType": "fixed"}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceApiDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_operation.py new file mode 100644 index 000000000000..3ff9cb247861 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_operation.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_api_operation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="PetStoreTemplate2", + operation_id="newoperations", + parameters={ + "properties": { + "description": "This can only be done by the logged in user.", + "displayName": "createUser2", + "method": "POST", + "request": { + "description": "Created user object", + "headers": [], + "queryParameters": [], + "representations": [ + {"contentType": "application/json", "schemaId": "592f6c1d0af5840ca8897f0c", "typeName": "User"} + ], + }, + "responses": [ + { + "description": "successful operation", + "headers": [], + "representations": [{"contentType": "application/xml"}, {"contentType": "application/json"}], + "statusCode": 200, + } + ], + "templateParameters": [], + "urlTemplate": "/user1", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceApiOperation.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_operation_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_operation_policy.py new file mode 100644 index 000000000000..0c6c4161e75a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_operation_policy.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_api_operation_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation_policy.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="5600b57e7e8880006a040001", + operation_id="5600b57e7e8880006a080001", + policy_id="policy", + parameters={ + "properties": { + "format": "xml", + "value": " ", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceApiOperationPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_policy.py new file mode 100644 index 000000000000..159201bbdd5f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_policy.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_api_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_policy.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="5600b57e7e8880006a040001", + policy_id="policy", + parameters={ + "properties": { + "format": "xml", + "value": " ", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceApiPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_release.py new file mode 100644 index 000000000000..8dc661e67d06 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_release.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_api_release.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_release.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="a1", + release_id="testrev", + parameters={ + "properties": { + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/a1", + "notes": "yahooagain", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceApiRelease.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_schema.py new file mode 100644 index 000000000000..e74cb17bffc1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_schema.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_api_schema.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_schema.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="59d6bb8f1f7fab13dc67ec9b", + schema_id="ec12520d-9d48-4e7b-8f39-698ca2ac63f1", + parameters={ + "properties": { + "contentType": "application/vnd.ms-azure-apim.xsd+xml", + "document": { + "value": '\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n' + }, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceApiSchema.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_version_set.py new file mode 100644 index 000000000000..e3ceede4ecc3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_api_version_set.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_api_version_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_version_set.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + version_set_id="api1", + parameters={ + "properties": { + "description": "Version configuration", + "displayName": "api set 1", + "versioningScheme": "Segment", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceApiVersionSet.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_backend_proxy_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_backend_proxy_backend.py new file mode 100644 index 000000000000..c89d841cbe37 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_backend_proxy_backend.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_backend_proxy_backend.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + backend_id="proxybackend", + parameters={ + "properties": { + "credentials": { + "authorization": {"parameter": "opensesma", "scheme": "Basic"}, + "header": {"x-my-1": ["val1", "val2"]}, + "query": {"sv": ["xx", "bb", "cc"]}, + }, + "description": "description5308", + "protocol": "http", + "proxy": {"password": "", "url": "http://192.168.1.1:8080", "username": "Contoso\\admin"}, + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "url": "https://backendname2644/", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceBackendProxyBackend.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_backend_service_fabric.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_backend_service_fabric.py new file mode 100644 index 000000000000..da8e9eb1c539 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_backend_service_fabric.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_backend_service_fabric.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + backend_id="sfbackend", + parameters={ + "properties": { + "description": "Service Fabric Test App 1", + "properties": { + "serviceFabricCluster": { + "clientCertificateId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/certificates/cert1", + "managementEndpoints": ["https://somecluster.com"], + "maxPartitionResolutionRetries": 5, + "serverX509Names": [ + {"issuerCertificateThumbprint": "IssuerCertificateThumbprint1", "name": "ServerCommonName1"} + ], + } + }, + "protocol": "http", + "url": "fabric:/mytestapp/mytestservice", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceBackendServiceFabric.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_certificate.py new file mode 100644 index 000000000000..314101aa50ee --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_certificate.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_certificate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_certificate.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + certificate_id="tempcert", + parameters={ + "properties": { + "data": "****************Base 64 Encoded Certificate *******************************", + "password": "****Certificate Password******", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_certificate_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_certificate_with_key_vault.py new file mode 100644 index 000000000000..6241b6c82977 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_certificate_with_key_vault.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_certificate_with_key_vault.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_certificate.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + certificate_id="templateCertkv", + parameters={ + "properties": { + "keyVault": { + "identityClientId": "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", + "secretIdentifier": "https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert", + } + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceCertificateWithKeyVault.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_diagnostic.py new file mode 100644 index 000000000000..bb4122df6363 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_diagnostic.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_diagnostic.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + diagnostic_id="applicationinsights", + parameters={ + "properties": { + "alwaysLog": "allErrors", + "backend": { + "request": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + "response": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + }, + "frontend": { + "request": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + "response": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + }, + "loggerId": "/workspaces/wks1/loggers/azuremonitor", + "sampling": {"percentage": 50, "samplingType": "fixed"}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_eh_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_eh_logger.py new file mode 100644 index 000000000000..4991ac6acc4e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_eh_logger.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_eh_logger.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_logger.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + logger_id="eh1", + parameters={ + "properties": { + "credentials": { + "connectionString": "Endpoint=sb://hydraeventhub-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=********=", + "name": "hydraeventhub", + }, + "description": "adding a new logger", + "loggerType": "azureEventHub", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceEHLogger.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group.py new file mode 100644 index 000000000000..ca7df21bb590 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="tempgroup", + parameters={"properties": {"displayName": "temp group"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group_external.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group_external.py new file mode 100644 index 000000000000..6fe7853476b3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group_external.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_group_external.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="aadGroup", + parameters={ + "properties": { + "description": "new group to test", + "displayName": "NewGroup (samiraad.onmicrosoft.com)", + "externalId": "aad://samiraad.onmicrosoft.com/groups/83cf2753-5831-4675-bc0e-2f8dc067c58d", + "type": "external", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceGroupExternal.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group_user.py new file mode 100644 index 000000000000..7c3fe3e99476 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_group_user.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_group_user.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group_user.create( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="tempgroup", + user_id="59307d350af58404d8a26300", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceGroupUser.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_named_value.py new file mode 100644 index 000000000000..4f47822ee802 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_named_value.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_named_value.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testprop2", + parameters={ + "properties": {"displayName": "prop3name", "secret": False, "tags": ["foo", "bar"], "value": "propValue"} + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceNamedValue.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_named_value_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_named_value_with_key_vault.py new file mode 100644 index 000000000000..26c5fd85b6df --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_named_value_with_key_vault.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_named_value_with_key_vault.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testprop6", + parameters={ + "properties": { + "displayName": "prop6namekv", + "keyVault": { + "identityClientId": "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", + "secretIdentifier": "https://contoso.vault.azure.net/secrets/aadSecret", + }, + "secret": True, + "tags": ["foo", "bar"], + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceNamedValueWithKeyVault.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification.py new file mode 100644 index 000000000000..cd35d94e3cda --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_notification.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceNotification.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification_recipient_email.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification_recipient_email.py new file mode 100644 index 000000000000..36616d2ca356 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification_recipient_email.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_notification_recipient_email.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification_recipient_email.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + email="foobar@live.com", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceNotificationRecipientEmail.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification_recipient_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification_recipient_user.py new file mode 100644 index 000000000000..c66c3a65a5d1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_notification_recipient_user.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_notification_recipient_user.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification_recipient_user.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + user_id="576823d0a40f7e74ec07d642", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceNotificationRecipientUser.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy.py new file mode 100644 index 000000000000..f636b668ec66 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + policy_id="policy", + parameters={ + "properties": { + "format": "xml", + "value": " ", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspacePolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy_fragment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy_fragment.py new file mode 100644 index 000000000000..0d21ff237cee --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy_fragment.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_policy_fragment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy_fragment.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + id="policyFragment1", + parameters={ + "properties": { + "description": "A policy fragment example", + "format": "xml", + "value": '', + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspacePolicyFragment.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy_non_xml_encoded.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy_non_xml_encoded.py new file mode 100644 index 000000000000..228b1365b500 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_policy_non_xml_encoded.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_policy_non_xml_encoded.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + policy_id="policy", + parameters={ + "properties": { + "format": "rawxml", + "value": '\r\n \r\n \r\n \r\n "@(context.Request.Headers.FirstOrDefault(h => h.Ke=="Via"))" \r\n \r\n \r\n ', + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspacePolicyNonXmlEncoded.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_premium_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_premium_gateway.py new file mode 100644 index 000000000000..13af9d10e9a4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_premium_gateway.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_premium_gateway.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway.begin_create_or_update( + resource_group_name="rg1", + gateway_name="apimGateway1", + parameters={ + "location": "South Central US", + "properties": { + "backend": { + "subnet": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vn1/subnets/sn1" + } + }, + "virtualNetworkType": "External", + }, + "sku": {"capacity": 1, "name": "WorkspaceGatewayPremium"}, + "tags": {"Name": "Contoso", "Test": "User"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspacePremiumGateway.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product.py new file mode 100644 index 000000000000..f0984b6df697 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_product.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + parameters={"properties": {"displayName": "Test Template ProductName 4"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceProduct.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_api_link.py new file mode 100644 index 000000000000..3d5b5b99eeda --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_api_link.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_product_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_api_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + api_link_id="link1", + parameters={ + "properties": { + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceProductApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_group_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_group_link.py new file mode 100644 index 000000000000..872d03f84a30 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_group_link.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_product_group_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_group_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + group_link_id="link1", + parameters={ + "properties": { + "groupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/groups/group1" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceProductGroupLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_policy.py new file mode 100644 index 000000000000..158a3e0ea4f8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_product_policy.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_product_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_policy.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="5702e97e5157a50f48dce801", + policy_id="policy", + parameters={ + "properties": { + "format": "xml", + "value": '\r\n \r\n \r\n \r\n @( string.Join(",", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n', + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceProductPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_schema.py new file mode 100644 index 000000000000..eb3cb7eaf72a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_schema.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_schema.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_global_schema.begin_create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + schema_id="schema1", + parameters={ + "properties": { + "description": "sample schema description", + "schemaType": "xml", + "value": '\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n', + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceSchema.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_subscription.py new file mode 100644 index 000000000000..4b0058ad656a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_subscription.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_subscription.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + sid="testsub", + parameters={ + "properties": { + "displayName": "testsub", + "ownerId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7", + "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/products/5600b59475ff190048060002", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag.py new file mode 100644 index 000000000000..c9a58244ba78 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_tag.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tagId1", + parameters={"properties": {"displayName": "tag1"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceTag.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_api_link.py new file mode 100644 index 000000000000..570ca5ab0311 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_api_link.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_tag_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_api_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + api_link_id="link1", + parameters={ + "properties": { + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceTagApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_operation_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_operation_link.py new file mode 100644 index 000000000000..b596e63a0393 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_operation_link.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_tag_operation_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_operation_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + operation_link_id="link1", + parameters={ + "properties": { + "operationId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api/operations/op1" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceTagOperationLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_product_link.py new file mode 100644 index 000000000000..01072821a18e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_workspace_tag_product_link.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_create_workspace_tag_product_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_product_link.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + product_link_id="link1", + parameters={ + "properties": { + "productId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/products/product1" + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementCreateWorkspaceTagProductLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api.py index 4bb68cfc66c1..ded0de420753 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api.py @@ -27,17 +27,17 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - client.api.delete( + client.api.begin_delete( resource_group_name="rg1", service_name="apimService1", api_id="echo-api", if_match="*", - ) + ).result() -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_diagnostic.py index 55a9dc1a41f9..7035874021b7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_diagnostic.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_diagnostic.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue.py index 827e38e93761..1e6887b2ead5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_issue.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiIssue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiIssue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue_attachment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue_attachment.py index 1827d3f8232f..f4be9a7d074b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue_attachment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue_attachment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_issue_attachment.delete( @@ -40,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiIssueAttachment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiIssueAttachment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue_comment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue_comment.py index 1827187fe125..1b2c2cb8d97a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue_comment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_issue_comment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_issue_comment.delete( @@ -40,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiIssueComment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiIssueComment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation.py index 18ef26a3d397..e00e0c00680f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_operation.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiOperation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiOperation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation_policy.py index cb4e6cb981a9..366a56562fc2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_operation_policy.delete( @@ -45,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiOperationPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiOperationPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation_tag.py index 0a5d3fe9e06a..def7ee940893 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_operation_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.tag.detach_from_operation( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiOperationTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiOperationTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_policy.py index 52a9df19721b..8bf9bd2d6b0e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_policy.delete( @@ -44,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_release.py index 202406766505..fa55ae2b575c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_release.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_release.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_release.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiRelease.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiRelease.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_schema.py index e3e6fe582d0e..593931b088e3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_schema.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_schema.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_schema.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiSchema.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiSchema.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tag.py index c948e711f62d..656463060a23 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.tag.detach_from_api( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tag_description.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tag_description.py index cddb3b56c747..fd94b498bc30 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tag_description.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tag_description.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_tag_description.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiTagDescription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiTagDescription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_version_set.py index 6b50c35a9e3f..147d8004d735 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_version_set.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_version_set.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_version_set.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiVersionSet.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiVersionSet.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_wiki.py index e52729d05db5..8d5f9440c78d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_wiki.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.api_wiki.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteApiWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization.py index f5732609c933..002db4f33c80 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.authorization.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteAuthorization.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteAuthorization.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_access_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_access_policy.py index 95e849238c7a..021b6311a666 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_access_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_access_policy.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.authorization_access_policy.delete( @@ -40,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteAuthorizationAccessPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteAuthorizationAccessPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_provider.py index cc7a5fb19f6e..22493cc972f5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_provider.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.authorization_provider.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteAuthorizationProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteAuthorizationProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_server.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_server.py index d25e8269a16e..9f16f413965b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_server.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_authorization_server.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.authorization_server.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteAuthorizationServer.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteAuthorizationServer.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_backend.py index 56494fb40d52..f3ceeb026578 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_backend.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_backend.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.backend.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteBackend.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteBackend.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_cache.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_cache.py index f41a809feaef..b9690485dfdf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_cache.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_cache.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.cache.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteCache.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteCache.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_certificate.py index b5a2f695a547..a7db341dd1fe 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_certificate.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_certificate.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.certificate.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteCertificate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteCertificate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_content_type.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_content_type.py index 6aa6ad3d4f19..54f85ef0ec21 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_content_type.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_content_type.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.content_type.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteContentType.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteContentType.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_content_type_content_item.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_content_type_content_item.py index 0fcec8d006aa..921f0795a67f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_content_type_content_item.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_content_type_content_item.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.content_item.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteContentTypeContentItem.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteContentTypeContentItem.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_diagnostic.py index 9c31ab72a752..2f7bac345f96 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_diagnostic.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.diagnostic.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway.py index 77f01bb30929..0fcb18b3d399 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.gateway.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGateway.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGateway.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_api.py index 00f48c23f97c..b2e2b69bf6a3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_api.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.gateway_api.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGatewayApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGatewayApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_certificate_authority.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_certificate_authority.py index 866810f0f7ea..ad0181d52ad7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_certificate_authority.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_certificate_authority.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.gateway_certificate_authority.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGatewayCertificateAuthority.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGatewayCertificateAuthority.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_config_connection.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_config_connection.py new file mode 100644 index 000000000000..d3ce160c00b0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_config_connection.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_gateway_config_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.api_gateway_config_connection.begin_delete( + resource_group_name="rg1", + gateway_name="standard-gw-01", + config_connection_name="gcc-01", + if_match="*", + ).result() + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGatewayConfigConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_hostname_configuration.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_hostname_configuration.py index 972a4837e74c..2b2245370828 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_hostname_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_hostname_configuration.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.gateway_hostname_configuration.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGatewayHostnameConfiguration.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGatewayHostnameConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_global_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_global_schema.py index cab1d5a319a5..ecb44cc861b6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_global_schema.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_global_schema.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.global_schema.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGlobalSchema.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGlobalSchema.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_graph_ql_api_resolver.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_graph_ql_api_resolver.py index 50c4c63ce963..aba5a1a90f56 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_graph_ql_api_resolver.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_graph_ql_api_resolver.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.graph_ql_api_resolver.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGraphQLApiResolver.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGraphQLApiResolver.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_graph_ql_api_resolver_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_graph_ql_api_resolver_policy.py index b3b873fff3d1..76f21fc86a21 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_graph_ql_api_resolver_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_graph_ql_api_resolver_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.graph_ql_api_resolver_policy.delete( @@ -45,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGraphQLApiResolverPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGraphQLApiResolverPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_group.py index 31ff1b1fe3dc..7a5094232fee 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_group.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.group.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_group_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_group_user.py index bb43bfbb2f9d..7c9d192f6fa0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_group_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_group_user.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.group_user.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGroupUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteGroupUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_identity_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_identity_provider.py index c694ca5a7ba6..619d0c33624b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_identity_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_identity_provider.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.identity_provider.delete( @@ -43,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteIdentityProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteIdentityProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_logger.py index 28317a5bfc68..718a530acb75 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_logger.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_logger.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.logger.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteLogger.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteLogger.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_named_value.py index f5c796873d3c..b4e10654fc5c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_named_value.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_named_value.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.named_value.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteNamedValue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteNamedValue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_notification_recipient_email.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_notification_recipient_email.py index 330851fa2b30..6570295ca963 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_notification_recipient_email.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_notification_recipient_email.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.notification_recipient_email.delete( @@ -43,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteNotificationRecipientEmail.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteNotificationRecipientEmail.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_notification_recipient_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_notification_recipient_user.py index 9a6b8e99742d..b12a4c1bd46b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_notification_recipient_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_notification_recipient_user.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.notification_recipient_user.delete( @@ -43,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteNotificationRecipientUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteNotificationRecipientUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_open_id_connect_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_open_id_connect_provider.py index 297712b1f5ea..71344874c613 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_open_id_connect_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_open_id_connect_provider.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.open_id_connect_provider.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteOpenIdConnectProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteOpenIdConnectProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy.py index 246c406b1791..408b9e64cbd5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.policy.delete( @@ -43,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletePolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeletePolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy_fragment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy_fragment.py index 74851e77959b..3b0b74ae00f3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy_fragment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy_fragment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.policy_fragment.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletePolicyFragment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeletePolicyFragment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy_restriction.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy_restriction.py new file mode 100644 index 000000000000..9d9a71739c19 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_policy_restriction.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_policy_restriction.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.policy_restriction.delete( + resource_group_name="rg1", + service_name="apimService1", + policy_restriction_id="policyRestriction1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeletePolicyRestriction.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_private_endpoint_connection.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_private_endpoint_connection.py index fc164db00fd8..e71789890ae8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_private_endpoint_connection.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_private_endpoint_connection.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.private_endpoint_connection.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletePrivateEndpointConnection.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeletePrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product.py index 7e1ddaec2635..f175ed6ccb4b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.product.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProduct.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteProduct.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_api.py index d97b1bba40d0..4766855ecfff 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_api.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.product_api.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteProductApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_api_link.py new file mode 100644 index 000000000000..8c5b5496175b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_api_link.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_product_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.product_api_link.delete( + resource_group_name="rg1", + service_name="apimService1", + product_id="testproduct", + api_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteProductApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_group.py index 2e9f5b417a6e..9268ebea1632 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_group.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.product_group.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteProductGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_group_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_group_link.py new file mode 100644 index 000000000000..13322f01ef82 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_group_link.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_product_group_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.product_group_link.delete( + resource_group_name="rg1", + service_name="apimService1", + product_id="testproduct", + group_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteProductGroupLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_policy.py index 874c469d4c5f..2b1bc6832b2b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.product_policy.delete( @@ -44,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteProductPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_tag.py index 0b12e0908788..1866da0f1c8b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.tag.detach_from_product( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteProductTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_wiki.py index 8d69fbdad9b7..0db99e9e0265 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_product_wiki.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.product_wiki.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteProductWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_subscription.py index cabb2c534cc3..ca0ecda38a0f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_subscription.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_subscription.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.subscription.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteSubscription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteSubscription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag.py index 7345d7055f2e..cd3601347e1c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.tag.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_api_link.py new file mode 100644 index 000000000000..8c0a3a2230aa --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_api_link.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_tag_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.tag_api_link.delete( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + api_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteTagApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_operation_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_operation_link.py new file mode 100644 index 000000000000..f33ed7f259df --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_operation_link.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_tag_operation_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.tag_operation_link.delete( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + operation_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteTagOperationLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_product_link.py new file mode 100644 index 000000000000..0cd89769298a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_tag_product_link.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_tag_product_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.tag_product_link.delete( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + product_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteTagProductLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_template.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_template.py index de0ce6f4a590..074cb29b8cb2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_template.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_template.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.email_template.delete( @@ -43,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteTemplate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteTemplate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_user.py index 91104a6c4bc1..51d32d721589 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_user.py @@ -27,17 +27,17 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - client.user.delete( + client.user.begin_delete( resource_group_name="rg1", service_name="apimService1", user_id="5931a75ae4bbd512288c680b", if_match="*", - ) + ).result() -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_documentation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace.py similarity index 83% rename from sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_documentation.py rename to sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace.py index e205a5b0b984..83897d81bc2f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_documentation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-apimanagement # USAGE - python api_management_delete_documentation.py + python api_management_delete_workspace.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -27,17 +27,17 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - client.documentation.delete( + client.workspace.delete( resource_group_name="rg1", service_name="apimService1", - documentation_id="57d1f7558aa04f15146d9d8a", + workspace_id="wks1", if_match="*", ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteDocumentation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspace.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api.py new file mode 100644 index 000000000000..20a179c9f872 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_api.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="echo-api", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceApi.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_diagnostic.py new file mode 100644 index 000000000000..f0feec8ba2c4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_diagnostic.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_api_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_api_diagnostic.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d1f7558aa04f15146d9d8a", + diagnostic_id="applicationinsights", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceApiDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_operation.py new file mode 100644 index 000000000000..d5a80f076196 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_operation.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_api_operation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_api_operation.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d2ef278aa04f0888cba3f3", + operation_id="57d2ef278aa04f0ad01d6cdc", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceApiOperation.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_operation_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_operation_policy.py new file mode 100644 index 000000000000..0592220147f6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_operation_policy.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_api_operation_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_api_operation_policy.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="testapi", + operation_id="testoperation", + policy_id="policy", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceApiOperationPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_policy.py new file mode 100644 index 000000000000..284c4daf4524 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_policy.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_api_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_api_policy.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="loggerId", + policy_id="policy", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceApiPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_release.py new file mode 100644 index 000000000000..ab9de33849be --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_release.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_api_release.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_api_release.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="5a5fcc09124a7fa9b89f2f1d", + release_id="testrev", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceApiRelease.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_schema.py new file mode 100644 index 000000000000..fcacdcd58b31 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_schema.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_api_schema.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_api_schema.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="59d5b28d1f7fab116c282650", + schema_id="59d5b28e1f7fab116402044e", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceApiSchema.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_version_set.py new file mode 100644 index 000000000000..42287a983183 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_api_version_set.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_api_version_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_api_version_set.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + version_set_id="a1", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceApiVersionSet.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_backend.py new file mode 100644 index 000000000000..ad09239e4ef5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_backend.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_backend.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_backend.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + backend_id="sfbackend", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceBackend.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_certificate.py new file mode 100644 index 000000000000..82885b67756b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_certificate.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_certificate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_certificate.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + certificate_id="tempcert", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_diagnostic.py new file mode 100644 index 000000000000..2d010de8b161 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_diagnostic.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_diagnostic.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + diagnostic_id="applicationinsights", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_group.py new file mode 100644 index 000000000000..760f5e5689d9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_group.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_group.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="aadGroup", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_group_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_group_user.py new file mode 100644 index 000000000000..c23d3503416f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_group_user.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_group_user.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_group_user.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="templategroup", + user_id="59307d350af58404d8a26300", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceGroupUser.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_logger.py new file mode 100644 index 000000000000..0345b4fcd062 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_logger.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_logger.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_logger.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + logger_id="loggerId", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceLogger.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_named_value.py new file mode 100644 index 000000000000..6c14ed6c3920 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_named_value.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_named_value.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_named_value.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testprop2", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceNamedValue.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_notification_recipient_email.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_notification_recipient_email.py new file mode 100644 index 000000000000..343adc550b7c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_notification_recipient_email.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_notification_recipient_email.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_notification_recipient_email.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + email="contoso@live.com", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceNotificationRecipientEmail.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_notification_recipient_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_notification_recipient_user.py new file mode 100644 index 000000000000..f623cd2849bc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_notification_recipient_user.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_notification_recipient_user.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_notification_recipient_user.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + user_id="576823d0a40f7e74ec07d642", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceNotificationRecipientUser.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_policy.py new file mode 100644 index 000000000000..1df50cad946b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_policy.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_policy.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + policy_id="policy", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspacePolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_policy_fragment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_policy_fragment.py new file mode 100644 index 000000000000..852638c6d693 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_policy_fragment.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_policy_fragment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_policy_fragment.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + id="policyFragment1", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspacePolicyFragment.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product.py new file mode 100644 index 000000000000..7c9476bd7544 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_product.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_product.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceProduct.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_api_link.py new file mode 100644 index 000000000000..cb1d3e877a21 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_api_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_product_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_product_api_link.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + api_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceProductApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_group_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_group_link.py new file mode 100644 index 000000000000..f251f8af5bda --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_group_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_product_group_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_product_group_link.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + group_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceProductGroupLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_policy.py new file mode 100644 index 000000000000..e574c40593d6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_product_policy.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_product_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_product_policy.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + policy_id="policy", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceProductPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_schema.py new file mode 100644 index 000000000000..d30cf4cc1beb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_schema.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_schema.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_global_schema.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + schema_id="schema1", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceSchema.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_subscription.py new file mode 100644 index 000000000000..1a65f8e8f168 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_subscription.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_subscription.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + sid="testsub", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag.py new file mode 100644 index 000000000000..0d5230be79eb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_tag.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_tag.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tagId1", + if_match="*", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceTag.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_api_link.py new file mode 100644 index 000000000000..ebb71baf0dde --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_api_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_tag_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_tag_api_link.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + api_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceTagApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_operation_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_operation_link.py new file mode 100644 index 000000000000..207645d2a23d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_operation_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_tag_operation_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_tag_operation_link.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + operation_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceTagOperationLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_product_link.py new file mode 100644 index 000000000000..7cc079fdce8f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace_tag_product_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_delete_workspace_tag_product_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_tag_product_link.delete( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + product_link_id="link1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeleteWorkspaceTagProductLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_deleted_services_list_by_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_deleted_services_list_by_subscription.py index ed919f3341fd..54b77361f025 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_deleted_services_list_by_subscription.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_deleted_services_list_by_subscription.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.deleted_services.list_by_subscription() @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletedServicesListBySubscription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeletedServicesListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_deleted_services_purge.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_deleted_services_purge.py index 06cd5675a080..67f1d24efc9a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_deleted_services_purge.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_deleted_services_purge.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.deleted_services.begin_purge( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletedServicesPurge.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementDeletedServicesPurge.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_delete_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_delete_gateway.py new file mode 100644 index 000000000000..9d704698a822 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_delete_gateway.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_gateway_delete_gateway.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway.begin_delete( + resource_group_name="rg1", + gateway_name="example-gateway", + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGatewayDeleteGateway.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_generate_token.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_generate_token.py index 0de4c30147b6..ff37826847ef 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_generate_token.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_generate_token.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway.generate_token( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGatewayGenerateToken.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGatewayGenerateToken.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_get_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_get_gateway.py new file mode 100644 index 000000000000..44a392f99614 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_get_gateway.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_gateway_get_gateway.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway.get( + resource_group_name="rg1", + gateway_name="apimService1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGatewayGetGateway.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_invalidate_debug_credentials.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_invalidate_debug_credentials.py new file mode 100644 index 000000000000..ab34e1ccd8b1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_invalidate_debug_credentials.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_gateway_invalidate_debug_credentials.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.gateway.invalidate_debug_credentials( + resource_group_name="rg1", + service_name="apimService1", + gateway_id="gw1", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGatewayInvalidateDebugCredentials.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_debug_credentials.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_debug_credentials.py new file mode 100644 index 000000000000..866ab29f7746 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_debug_credentials.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_gateway_list_debug_credentials.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.gateway.list_debug_credentials( + resource_group_name="rg1", + service_name="apimService1", + gateway_id="gw1", + parameters={ + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1", + "credentialsExpireAfter": "PT1H", + "purposes": ["tracing"], + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGatewayListDebugCredentials.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_keys.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_keys.py index 6f684b85ba1a..c375f52c23d3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_keys.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_keys.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway.list_keys( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGatewayListKeys.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGatewayListKeys.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_trace.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_trace.py new file mode 100644 index 000000000000..421de8595e8a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_list_trace.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_gateway_list_trace.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.gateway.list_trace( + resource_group_name="rg1", + service_name="apimService1", + gateway_id="gw1", + parameters={"traceId": "CrDvXXXXXXXXXXXXXVU3ZA2-1"}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGatewayListTrace.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_regenerate_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_regenerate_key.py index d8ca06e71e5a..fc00162b66f5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_regenerate_key.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_gateway_regenerate_key.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.gateway.regenerate_key( @@ -40,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGatewayRegenerateKey.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGatewayRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_contract.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_contract.py index 8ee81c7656b4..af630887676f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_contract.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_contract.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiContract.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiContract.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_diagnostic.py index 2964b8c270c8..5981065f2e77 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_diagnostic.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_diagnostic.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_export_in_open_api2dot0.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_export_in_open_api2dot0.py index 5e40f4521d23..11355ec47a2e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_export_in_open_api2dot0.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_export_in_open_api2dot0.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_export.get( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiExportInOpenApi2dot0.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiExportInOpenApi2dot0.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_export_in_open_api3dot0.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_export_in_open_api3dot0.py index f3b9bccce595..f669f6396fdc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_export_in_open_api3dot0.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_export_in_open_api3dot0.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_export.get( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiExportInOpenApi3dot0.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiExportInOpenApi3dot0.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue.py index 96e02aee1f79..8c84446d9115 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiIssue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiIssue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue_attachment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue_attachment.py index 2ddf67d2b24c..8f96e19587c1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue_attachment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue_attachment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue_attachment.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiIssueAttachment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiIssueAttachment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue_comment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue_comment.py index a37524cc58d7..b0d04bf92adb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue_comment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_issue_comment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue_comment.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiIssueComment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiIssueComment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation.py index dc700cfa8f56..5b958f1dc238 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiOperation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiOperation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_pet_store.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_pet_store.py index 908036d62923..a1b98ef7af9b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_pet_store.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_pet_store.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiOperationPetStore.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiOperationPetStore.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_policy.py index 25de9d95fe29..8b8a599d72c0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation_policy.get( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiOperationPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiOperationPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_tag.py index ddb5a13fd4a3..bf95ac542871 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_operation_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.get_by_operation( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiOperationTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiOperationTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_policy.py index e0a7e30f5427..ab821d0edd30 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_policy.get( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_release.py index 02614487f48d..e4d224ab3afc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_release.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_release.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_release.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiRelease.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiRelease.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_revision.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_revision.py index 41db9662047e..13159adf79c5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_revision.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_revision.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiRevision.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiRevision.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_schema.py index 37912612399e..86344ad239cf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_schema.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_schema.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_schema.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiSchema.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiSchema.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tag.py index 2f4385e8cd49..0ff06422dc30 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.get_by_api( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tag_description.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tag_description.py index 32e617f9d396..a335eda9c40e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tag_description.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tag_description.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_tag_description.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiTagDescription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiTagDescription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_version_set.py index 4bb0d23484a9..a6077cdf15a3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_version_set.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_version_set.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_version_set.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiVersionSet.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiVersionSet.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_wiki.py index 29e84e21edc9..4f8546f44c81 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_wiki.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_wiki.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetApiWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization.py index 08d36cea5fed..774bcc15886b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorization.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetAuthorization.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_access_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_access_policy.py index 495a8a8ae81e..4c65cb6ad905 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_access_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_access_policy.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_access_policy.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorizationAccessPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetAuthorizationAccessPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_login_request.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_login_request.py index 4dc17670ea5d..7cb3475e6fbd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_login_request.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_login_request.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_login_links.post( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorizationLoginRequest.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetAuthorizationLoginRequest.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_provider.py index 9ea39097ab71..3f5e40f30419 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_provider.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_provider.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorizationProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetAuthorizationProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_server.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_server.py index 6affc8c4ebec..39a4bc35b6fb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_server.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_authorization_server.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_server.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorizationServer.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetAuthorizationServer.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_backend.py index 444ff20108c4..52163c8fe6ba 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_backend.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_backend.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.backend.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetBackend.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetBackend.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_cache.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_cache.py index 2059cee7c260..fafb06b9d769 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_cache.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_cache.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.cache.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetCache.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetCache.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_certificate.py index 91e7c6b67ba3..1eee86a3de0b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_certificate.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_certificate.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.certificate.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetCertificate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetCertificate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_certificate_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_certificate_with_key_vault.py index 5e2dde379d7e..b0675c8d1e98 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_certificate_with_key_vault.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_certificate_with_key_vault.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.certificate.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetCertificateWithKeyVault.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetCertificateWithKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_content_type.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_content_type.py index c4a2e511c263..51470b970e67 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_content_type.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_content_type.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.content_type.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetContentType.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetContentType.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_content_type_content_item.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_content_type_content_item.py index 803cde0ee5e3..1fabad171d6a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_content_type_content_item.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_content_type_content_item.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.content_item.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetContentTypeContentItem.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetContentTypeContentItem.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_deleted_service_by_name.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_deleted_service_by_name.py index ae186cb7e7ba..1e6cabd725db 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_deleted_service_by_name.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_deleted_service_by_name.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.deleted_services.get_by_name( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetDeletedServiceByName.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetDeletedServiceByName.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_diagnostic.py index b630143394d4..79bf5cd37923 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_diagnostic.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.diagnostic.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_documentation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_documentation.py index c49cdbe4b441..08888258c87c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_documentation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_documentation.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.documentation.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetDocumentation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetDocumentation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway.py index 9a3bd49a369d..2f3074e1c22d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGateway.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGateway.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_certificate_authority.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_certificate_authority.py index b00c32221a67..860b15781c3a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_certificate_authority.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_certificate_authority.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_certificate_authority.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGatewayCertificateAuthority.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGatewayCertificateAuthority.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_config_connection.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_config_connection.py new file mode 100644 index 000000000000..31aacd199acc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_config_connection.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_gateway_config_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway_config_connection.get( + resource_group_name="rg1", + gateway_name="standard-gw-01", + config_connection_name="gcc-01", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGatewayConfigConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_hostname_configuration.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_hostname_configuration.py index d24d55c66755..4bcca51089e1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_hostname_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_hostname_configuration.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_hostname_configuration.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGatewayHostnameConfiguration.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGatewayHostnameConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_global_schema1.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_global_schema1.py index c889aa01b480..e55b28c6470f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_global_schema1.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_global_schema1.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.global_schema.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGlobalSchema1.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGlobalSchema1.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_global_schema2.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_global_schema2.py index 3f052c323de3..a3ddd0d57ea9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_global_schema2.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_global_schema2.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.global_schema.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGlobalSchema2.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGlobalSchema2.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_graph_ql_api_resolver.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_graph_ql_api_resolver.py index 5116772f83da..495fd751074a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_graph_ql_api_resolver.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_graph_ql_api_resolver.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGraphQLApiResolver.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGraphQLApiResolver.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_graph_ql_api_resolver_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_graph_ql_api_resolver_policy.py index cd11ba532dd6..cc5457f2a376 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_graph_ql_api_resolver_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_graph_ql_api_resolver_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver_policy.get( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGraphQLApiResolverPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGraphQLApiResolverPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_group.py index 0d89263d91f1..d2ac264d988a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_group.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_identity_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_identity_provider.py index 09e7f6d9c4b3..f09d0c472849 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_identity_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_identity_provider.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.identity_provider.get( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetIdentityProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetIdentityProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_issue.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_issue.py index 8c040c16e68f..eeba6d3414f3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_issue.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_issue.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.issue.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetIssue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetIssue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_logger.py index f6f4e24c9d4a..47801fb68a67 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_logger.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_logger.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.logger.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetLogger.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetLogger.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_named_value.py index 176e4d9fe2c7..dc6b63ba174c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_named_value.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_named_value.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetNamedValue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetNamedValue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_named_value_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_named_value_with_key_vault.py index 5712f4498e3a..c3a12671e46f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_named_value_with_key_vault.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_named_value_with_key_vault.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetNamedValueWithKeyVault.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetNamedValueWithKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_notification.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_notification.py index e6fead4414bb..97b2bb86d8d0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_notification.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_notification.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification.get( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetNotification.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetNotification.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_open_id_connect_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_open_id_connect_provider.py index 423019a12081..ae2aee2dc467 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_open_id_connect_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_open_id_connect_provider.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.open_id_connect_provider.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetOpenIdConnectProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetOpenIdConnectProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_operation_result.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_operation_result.py new file mode 100644 index 000000000000..e18aa28a65f5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_operation_result.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_operation_result.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.operations_results.get( + location="westus2", + operation_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetOperationResult.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_operation_status.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_operation_status.py new file mode 100644 index 000000000000..5610df051625 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_operation_status.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_operation_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.operation_status.get( + location="testLocation", + operation_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetOperationStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy.py index e612230cf757..9084c4815da1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy.get( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_format.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_format.py index 12a600ddbdc8..10d377415f3a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_format.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_format.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy.get( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPolicyFormat.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetPolicyFormat.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_fragment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_fragment.py index 533027279d66..d777b3386717 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_fragment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_fragment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy_fragment.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPolicyFragment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetPolicyFragment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_fragment_format.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_fragment_format.py index b9546109675a..f78b1ce0c2e2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_fragment_format.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_fragment_format.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy_fragment.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPolicyFragmentFormat.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetPolicyFragmentFormat.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_restriction.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_restriction.py new file mode 100644 index 000000000000..9d44e327f1df --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_policy_restriction.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_policy_restriction.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.policy_restriction.get( + resource_group_name="rg1", + service_name="apimService1", + policy_restriction_id="policyRestriction1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetPolicyRestriction.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_portal_revision.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_portal_revision.py index 45dfbfdffd76..446e98bf48ce 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_portal_revision.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_portal_revision.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_revision.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPortalRevision.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetPortalRevision.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_private_endpoint_connection.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_private_endpoint_connection.py index 8e29d2e0b881..33d481294a4f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_private_endpoint_connection.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_private_endpoint_connection.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.private_endpoint_connection.get_by_name( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPrivateEndpointConnection.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetPrivateEndpointConnection.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_private_link_group_resource.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_private_link_group_resource.py index eb867e0cd4ea..451ad8cf6a5c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_private_link_group_resource.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_private_link_group_resource.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.private_endpoint_connection.get_private_link_resource( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPrivateLinkGroupResource.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetPrivateLinkGroupResource.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product.py index 4344d348dc72..35e870f907b2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetProduct.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetProduct.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_api_link.py new file mode 100644 index 000000000000..1dcf8a7a03e6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_api_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_product_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.product_api_link.get( + resource_group_name="rg1", + service_name="apimService1", + product_id="testproduct", + api_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetProductApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_group_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_group_link.py new file mode 100644 index 000000000000..cdc2ed4f748c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_group_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_product_group_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.product_group_link.get( + resource_group_name="rg1", + service_name="apimService1", + product_id="testproduct", + group_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetProductGroupLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_policy.py index a3e668e5dc6c..5730579dd304 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_policy.get( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetProductPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetProductPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_tag.py index 714e96baa7dc..fe9dd639eddb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.get_by_product( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetProductTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetProductTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_wiki.py index 75f97bdb7608..29614ec4bcb7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_product_wiki.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_wiki.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetProductWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetProductWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_quota_counter_keys.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_quota_counter_keys.py index 61f0b35132ae..de7d5bd49b2b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_quota_counter_keys.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_quota_counter_keys.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.quota_by_counter_keys.list_by_service( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetQuotaCounterKeys.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetQuotaCounterKeys.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_quota_counter_keys_by_quota_period.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_quota_counter_keys_by_quota_period.py index a14df6e14f5a..e638decbd62a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_quota_counter_keys_by_quota_period.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_quota_counter_keys_by_quota_period.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.quota_by_period_keys.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetQuotaCounterKeysByQuotaPeriod.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetQuotaCounterKeysByQuotaPeriod.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_api.py new file mode 100644 index 000000000000..108245d21526 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_api.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_reports_by_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.reports.list_by_api( + resource_group_name="rg1", + service_name="apimService1", + filter="timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetReportsByApi.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_geo.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_geo.py new file mode 100644 index 000000000000..3894a4f5a535 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_geo.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_reports_by_geo.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.reports.list_by_geo( + resource_group_name="rg1", + service_name="apimService1", + filter="timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetReportsByGeo.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_operation.py new file mode 100644 index 000000000000..ebe7f1748dc9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_operation.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_reports_by_operation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.reports.list_by_operation( + resource_group_name="rg1", + service_name="apimService1", + filter="timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetReportsByOperation.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_product.py new file mode 100644 index 000000000000..24d6eb8be3aa --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_product.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_reports_by_product.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.reports.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + filter="timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetReportsByProduct.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_request.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_request.py new file mode 100644 index 000000000000..30c9a6b30d88 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_request.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_reports_by_request.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.reports.list_by_request( + resource_group_name="rg1", + service_name="apimService1", + filter="timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetReportsByRequest.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_subscription.py new file mode 100644 index 000000000000..27f0096dad19 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_subscription.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_reports_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.reports.list_by_subscription( + resource_group_name="rg1", + service_name="apimService1", + filter="timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetReportsBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_time.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_time.py new file mode 100644 index 000000000000..23616c17069a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_time.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import isodate + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_reports_by_time.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.reports.list_by_time( + resource_group_name="rg1", + service_name="apimService1", + filter="timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", + interval=isodate.parse_duration("PT15M"), + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetReportsByTime.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_user.py new file mode 100644 index 000000000000..775215977258 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_reports_by_user.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_reports_by_user.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.reports.list_by_user( + resource_group_name="rg1", + service_name="apimService1", + filter="timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetReportsByUser.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_subscription.py index 4ec7c62ac178..ccae3aef34e8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_subscription.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_subscription.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.subscription.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetSubscription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetSubscription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag.py index 304f4ec47d3f..104db9901a5e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_api_link.py new file mode 100644 index 000000000000..55454a9f73a4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_api_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_tag_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_api_link.get( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + api_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetTagApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_operation_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_operation_link.py new file mode 100644 index 000000000000..22769c6ece58 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_operation_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_tag_operation_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_operation_link.get( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + operation_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetTagOperationLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_product_link.py new file mode 100644 index 000000000000..43a2c29cc7e1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tag_product_link.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_tag_product_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_product_link.get( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + product_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetTagProductLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_template.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_template.py index 9c3a204d67f4..45ef72c409ae 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_template.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_template.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.email_template.get( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTemplate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetTemplate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_access.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_access.py index 842d3d94bb27..3c72a0c4c6d3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_access.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_access.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_access.get( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTenantAccess.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetTenantAccess.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_git_access.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_git_access.py index 0d9f70892ff5..587affc97793 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_git_access.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_git_access.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_access.get( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTenantGitAccess.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetTenantGitAccess.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_settings.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_settings.py index ccd5bcdef0a8..d81883ff88df 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_settings.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_tenant_settings.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_settings.get( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTenantSettings.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetTenantSettings.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_user.py index 5b147fe993e8..49dd3a9aecf0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_user.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_user_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_user_subscription.py index c9c15c2c77cd..59a5dd1a5739 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_user_subscription.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_user_subscription.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user_subscription.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetUserSubscription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetUserSubscription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace.py new file mode 100644 index 000000000000..35bf652a5a13 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspace.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_contract.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_contract.py new file mode 100644 index 000000000000..068a5604c1d7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_contract.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_contract.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d1f7558aa04f15146d9d8a", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiContract.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_diagnostic.py new file mode 100644 index 000000000000..7686e600aaaf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_diagnostic.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_diagnostic.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d1f7558aa04f15146d9d8a", + diagnostic_id="applicationinsights", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_export_in_open_api2dot0.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_export_in_open_api2dot0.py new file mode 100644 index 000000000000..c02e590638b4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_export_in_open_api2dot0.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_export_in_open_api2dot0.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_export.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="echo-api", + format="swagger-link", + export="true", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiExportInOpenApi2dot0.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_export_in_open_api3dot0.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_export_in_open_api3dot0.py new file mode 100644 index 000000000000..4c1f3a3f0a7e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_export_in_open_api3dot0.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_export_in_open_api3dot0.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_export.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="aid9676", + format="openapi-link", + export="true", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiExportInOpenApi3dot0.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_operation.py new file mode 100644 index 000000000000..a2ec49156ed0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_operation.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_operation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d2ef278aa04f0888cba3f3", + operation_id="57d2ef278aa04f0ad01d6cdc", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiOperation.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_operation_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_operation_policy.py new file mode 100644 index 000000000000..cac19bc105e7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_operation_policy.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_operation_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation_policy.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="5600b539c53f5b0062040001", + operation_id="5600b53ac53f5b0062080006", + policy_id="policy", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiOperationPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_policy.py new file mode 100644 index 000000000000..30be198e628b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_policy.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_policy.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="5600b59475ff190048040001", + policy_id="policy", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_release.py new file mode 100644 index 000000000000..a491f6c8eba3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_release.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_release.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_release.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="a1", + release_id="5a7cb545298324c53224a799", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiRelease.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_revision.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_revision.py new file mode 100644 index 000000000000..10af8a87f3f7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_revision.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_revision.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="echo-api;rev=3", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiRevision.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_schema.py new file mode 100644 index 000000000000..b8455cfbdcdd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_schema.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_schema.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_schema.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="59d6bb8f1f7fab13dc67ec9b", + schema_id="ec12520d-9d48-4e7b-8f39-698ca2ac63f1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiSchema.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_version_set.py new file mode 100644 index 000000000000..0cf611805868 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_api_version_set.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_api_version_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_version_set.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + version_set_id="vs1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceApiVersionSet.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_backend.py new file mode 100644 index 000000000000..0c5397a4a670 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_backend.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_backend.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_backend.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + backend_id="sfbackend", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceBackend.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_certificate.py new file mode 100644 index 000000000000..fa3307a96381 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_certificate.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_certificate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_certificate.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + certificate_id="templateCert1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_certificate_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_certificate_with_key_vault.py new file mode 100644 index 000000000000..d0fbc0206b5d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_certificate_with_key_vault.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_certificate_with_key_vault.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_certificate.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + certificate_id="templateCertkv", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceCertificateWithKeyVault.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_diagnostic.py new file mode 100644 index 000000000000..1e9373e8e1ef --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_diagnostic.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_diagnostic.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + diagnostic_id="applicationinsights", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_group.py new file mode 100644 index 000000000000..6f0bbe6a6a33 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_group.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="59306a29e4bbd510dc24e5f9", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_link.py new file mode 100644 index 000000000000..f56846ac05f7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_link.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_management_workspace_link.get( + resource_group_name="rg1", + service_name="service1", + workspace_id="wk-1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_logger.py new file mode 100644 index 000000000000..dd447edfe1a5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_logger.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_logger.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_logger.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + logger_id="templateLogger", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceLogger.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_named_value.py new file mode 100644 index 000000000000..638ed9dd2bca --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_named_value.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_named_value.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testarmTemplateproperties2", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceNamedValue.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_named_value_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_named_value_with_key_vault.py new file mode 100644 index 000000000000..d4a5ad91e96b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_named_value_with_key_vault.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_named_value_with_key_vault.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testprop6", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_notification.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_notification.py new file mode 100644 index 000000000000..fdc0d879cf2f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_notification.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_notification.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceNotification.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy.py new file mode 100644 index 000000000000..287e285fd6a9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + policy_id="policy", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspacePolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy_fragment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy_fragment.py new file mode 100644 index 000000000000..7e4dca1c51da --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy_fragment.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_policy_fragment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy_fragment.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + id="policyFragment1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspacePolicyFragment.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy_fragment_format.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy_fragment_format.py new file mode 100644 index 000000000000..063686ed1b50 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_policy_fragment_format.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_policy_fragment_format.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy_fragment.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + id="policyFragment1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspacePolicyFragmentFormat.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product.py new file mode 100644 index 000000000000..2a859408a913 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_product.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="unlimited", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceProduct.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_api_link.py new file mode 100644 index 000000000000..0eb29dc71810 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_api_link.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_product_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_api_link.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + api_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceProductApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_group_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_group_link.py new file mode 100644 index 000000000000..0f16aec7ddff --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_group_link.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_product_group_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_group_link.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + group_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceProductGroupLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_policy.py new file mode 100644 index 000000000000..8c66203bffa4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_product_policy.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_product_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_policy.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="kjoshiarmTemplateProduct4", + policy_id="policy", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceProductPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_schema.py new file mode 100644 index 000000000000..e82c7ced48cf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_schema.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_schema.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_global_schema.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + schema_id="schema1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceSchema.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_subscription.py new file mode 100644 index 000000000000..ad723feeea3a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_subscription.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_subscription.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + sid="5931a769d8d14f0ad8ce13b8", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag.py new file mode 100644 index 000000000000..3664194f5595 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_tag.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="59306a29e4bbd510dc24e5f9", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceTag.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_api_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_api_link.py new file mode 100644 index 000000000000..979044916de3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_api_link.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_tag_api_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_api_link.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + api_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceTagApiLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_operation_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_operation_link.py new file mode 100644 index 000000000000..e755774efb90 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_operation_link.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_tag_operation_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_operation_link.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + operation_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceTagOperationLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_product_link.py new file mode 100644 index 000000000000..265035cf6374 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_workspace_tag_product_link.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_get_workspace_tag_product_link.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_product_link.get( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + product_link_id="link1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementGetWorkspaceTagProductLink.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api.py index fa6a8254731f..5be72fbbab85 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_diagnostic.py index 69e3d19e16a4..696266917745 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_diagnostic.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_diagnostic.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue.py index e14412375162..f90cab1acc68 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiIssue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiIssue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue_attachment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue_attachment.py index dd109e0acd9d..3c9e248c84a0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue_attachment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue_attachment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue_attachment.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiIssueAttachment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiIssueAttachment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue_comment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue_comment.py index 0697ddcf1a14..4dfcc395d0f2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue_comment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_issue_comment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue_comment.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiIssueComment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiIssueComment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation.py index 17b92ca7768b..bf7083983322 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiOperation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiOperation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation_policy.py index 823e15e466f5..c410f0ce4d19 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation_policy.get_entity_tag( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiOperationPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiOperationPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation_tag.py index 0abd86a040d2..7f6d79be28cd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_operation_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.get_entity_state_by_operation( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiOperationTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiOperationTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_policy.py index 75c6a181138a..68ef7407e155 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_policy.get_entity_tag( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_release.py index 21010d3f5c22..502a7e26a121 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_release.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_release.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_release.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiRelease.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiRelease.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_schema.py index bb17e74b3501..43c081915d92 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_schema.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_schema.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_schema.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiSchema.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiSchema.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tag.py index 59b2f956fcc6..9621d6dbb3d7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.get_entity_state_by_api( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tag_description.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tag_description.py index f7a78ea3b0ce..63b633f9c6dc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tag_description.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tag_description.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_tag_description.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiTagDescription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiTagDescription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_version_set.py index 426a77bda173..6365f25d6847 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_version_set.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_version_set.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_version_set.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiVersionSet.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiVersionSet.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_wiki.py index 913a51103a25..45d6497b1460 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_wiki.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_wiki.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadApiWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_authorization_server.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_authorization_server.py index a381f0f36882..a7510d21ae90 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_authorization_server.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_authorization_server.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_server.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadAuthorizationServer.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadAuthorizationServer.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_backend.py index 83168b195f87..c3d6f0670a1b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_backend.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_backend.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.backend.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadBackend.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadBackend.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_cache.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_cache.py index 33ed80ec6736..29abf98e275e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_cache.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_cache.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.cache.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadCache.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadCache.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_certificate.py index 1c6fef00183e..b9ef4b466379 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_certificate.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_certificate.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.certificate.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadCertificate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadCertificate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_content_type_content_item.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_content_type_content_item.py index 1fb26995b567..26edee42d0f2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_content_type_content_item.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_content_type_content_item.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.content_item.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadContentTypeContentItem.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadContentTypeContentItem.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_delegation_settings.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_delegation_settings.py index 07e61eb3e26a..f409f65a09e5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_delegation_settings.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_delegation_settings.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.delegation_settings.get_entity_tag( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadDelegationSettings.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadDelegationSettings.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_diagnostic.py index e0ff879c0cd0..eb444e744add 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_diagnostic.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.diagnostic.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_documentation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_documentation.py index 4859e3c3ed1c..49543ff0af61 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_documentation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_documentation.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.documentation.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadDocumentation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadDocumentation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_email_template.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_email_template.py index c23c8798a09e..4bfc6a704643 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_email_template.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_email_template.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.email_template.get_entity_tag( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadEmailTemplate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadEmailTemplate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway.py index fc825ecd2701..9fdbd8c2d3cc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGateway.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGateway.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_api.py index 0b5d95a30e50..bb477fed2d8a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_api.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_api.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGatewayApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGatewayApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_certificate_authority.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_certificate_authority.py index c39349f69bc3..9d9c0d436174 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_certificate_authority.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_certificate_authority.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_certificate_authority.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGatewayCertificateAuthority.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGatewayCertificateAuthority.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_hostname_configuration.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_hostname_configuration.py index bd2985e38370..64a8ecdd3d37 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_hostname_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_gateway_hostname_configuration.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_hostname_configuration.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGatewayHostnameConfiguration.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGatewayHostnameConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_global_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_global_schema.py index 73b5e9a755e0..2ae09a199a87 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_global_schema.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_global_schema.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.global_schema.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGlobalSchema.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGlobalSchema.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_graph_ql_api_resolver.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_graph_ql_api_resolver.py index 8d3a703f247d..da312fef9414 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_graph_ql_api_resolver.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_graph_ql_api_resolver.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGraphQLApiResolver.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGraphQLApiResolver.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_graph_ql_api_resolver_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_graph_ql_api_resolver_policy.py index b59b6c16f3d6..7a61f4706660 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_graph_ql_api_resolver_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_graph_ql_api_resolver_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver_policy.get_entity_tag( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGraphQLApiResolverPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGraphQLApiResolverPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_group.py index 09d777bbe89d..339642c038b8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_group.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_group_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_group_user.py index 680f91adbf03..0be90d56f1ec 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_group_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_group_user.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group_user.check_entity_exists( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGroupUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadGroupUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_identity_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_identity_provider.py index 6f1a1e326fbc..c222ed7f8a27 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_identity_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_identity_provider.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.identity_provider.get_entity_tag( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadIdentityProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadIdentityProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_logger.py index d5df7d5035c9..e2bdde7ef333 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_logger.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_logger.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.logger.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadLogger.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadLogger.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_named_value.py index 308ae8c661d9..0c36e630acaa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_named_value.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_named_value.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadNamedValue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadNamedValue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_notification_recipient_email.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_notification_recipient_email.py index 22c3a914e3bc..bdaf1ebe2c67 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_notification_recipient_email.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_notification_recipient_email.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification_recipient_email.check_entity_exists( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadNotificationRecipientEmail.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadNotificationRecipientEmail.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_notification_recipient_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_notification_recipient_user.py index 2d351234745b..5e67c6709d4c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_notification_recipient_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_notification_recipient_user.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification_recipient_user.check_entity_exists( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadNotificationRecipientUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadNotificationRecipientUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_open_id_connect_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_open_id_connect_provider.py index a2b5a4dd1e7e..51293c1d46df 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_open_id_connect_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_open_id_connect_provider.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.open_id_connect_provider.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadOpenIdConnectProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadOpenIdConnectProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy.py index a0f21c9c33de..4ed129273bbd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy.get_entity_tag( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy_fragment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy_fragment.py index f5199c4e62a8..d738aa26dc68 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy_fragment.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy_fragment.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy_fragment.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadPolicyFragment.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadPolicyFragment.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy_restriction.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy_restriction.py new file mode 100644 index 000000000000..2224c4b16919 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_policy_restriction.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_policy_restriction.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.policy_restriction.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + policy_restriction_id="policyRestriction1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadPolicyRestriction.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_portal_config.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_portal_config.py index d76e767552f6..e58c313ba052 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_portal_config.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_portal_config.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_config.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadPortalConfig.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadPortalConfig.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_portal_revision.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_portal_revision.py index 6d5884bf6a1e..5262cc2f4727 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_portal_revision.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_portal_revision.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_revision.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadPortalRevision.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadPortalRevision.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product.py index 8128364c4409..0a019ce1e397 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProduct.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadProduct.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_api.py index 5d2984ffdd3f..d0359c2eb42a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_api.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_api.check_entity_exists( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadProductApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_group.py index b5f96211110f..a4cd6cee7ff1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_group.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_group.check_entity_exists( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadProductGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_policy.py index e0fbf44a6d74..f07f4e5f868d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_policy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_policy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_policy.get_entity_tag( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductPolicy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadProductPolicy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_tag.py index 5b579233fa9e..d7f5fc47f43c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.get_entity_state_by_product( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadProductTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_wiki.py index f477a3200d8a..121f7630b6e9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_product_wiki.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_wiki.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadProductWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_sign_in_settings.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_sign_in_settings.py index 10568a84d4fb..93de098e569f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_sign_in_settings.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_sign_in_settings.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.sign_in_settings.get_entity_tag( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadSignInSettings.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadSignInSettings.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_sign_up_settings.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_sign_up_settings.py index cf1fe60a58b2..d0bfe0dffa6c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_sign_up_settings.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_sign_up_settings.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.sign_up_settings.get_entity_tag( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadSignUpSettings.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadSignUpSettings.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_subscription.py index 7483cf7c7da2..591e092919ad 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_subscription.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_subscription.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.subscription.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadSubscription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadSubscription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_tag.py index fae18a63cb73..a395a58272cb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_tag.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.get_entity_state( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_tenant_access.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_tenant_access.py index fb0021a39194..74096d7cb473 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_tenant_access.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_tenant_access.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_access.get_entity_tag( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadTenantAccess.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadTenantAccess.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_user.py index b0c1433401bd..8385a3e920ed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_user.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace.py new file mode 100644 index 000000000000..d67ab9368dc3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspace.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api.py new file mode 100644 index 000000000000..4dcc4849bea2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d1f7558aa04f15146d9d8a", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceApi.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_diagnostic.py new file mode 100644 index 000000000000..23f6c179bcc2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_diagnostic.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_api_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_diagnostic.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d1f7558aa04f15146d9d8a", + diagnostic_id="applicationinsights", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceApiDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_operation.py new file mode 100644 index 000000000000..f6f908ec0c43 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_operation.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_api_operation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d2ef278aa04f0888cba3f3", + operation_id="57d2ef278aa04f0ad01d6cdc", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceApiOperation.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_operation_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_operation_policy.py new file mode 100644 index 000000000000..bf9e5fa5d394 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_operation_policy.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_api_operation_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation_policy.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="5600b539c53f5b0062040001", + operation_id="5600b53ac53f5b0062080006", + policy_id="policy", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceApiOperationPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_policy.py new file mode 100644 index 000000000000..1a6951e5f7fb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_policy.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_api_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_policy.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d1f7558aa04f15146d9d8a", + policy_id="policy", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceApiPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_release.py new file mode 100644 index 000000000000..b83f707a6a72 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_release.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_api_release.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_release.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="a1", + release_id="5a7cb545298324c53224a799", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceApiRelease.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_schema.py new file mode 100644 index 000000000000..53a41f2f278e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_schema.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_api_schema.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_schema.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d1f7558aa04f15146d9d8a", + schema_id="ec12520d-9d48-4e7b-8f39-698ca2ac63f1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceApiSchema.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_version_set.py new file mode 100644 index 000000000000..8bdedf751df2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_api_version_set.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_api_version_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_version_set.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + version_set_id="vs1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceApiVersionSet.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_backend.py new file mode 100644 index 000000000000..763f787bf1a5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_backend.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_backend.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_backend.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + backend_id="sfbackend", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceBackend.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_certificate.py new file mode 100644 index 000000000000..cca10d10706c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_certificate.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_certificate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_certificate.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + certificate_id="templateCert1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_diagnostic.py new file mode 100644 index 000000000000..577cf4d82e12 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_diagnostic.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_diagnostic.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + diagnostic_id="applicationinsights", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_group.py new file mode 100644 index 000000000000..8de391560337 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_group.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="59306a29e4bbd510dc24e5f9", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_group_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_group_user.py new file mode 100644 index 000000000000..a472e3adb832 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_group_user.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_group_user.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group_user.check_entity_exists( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="59306a29e4bbd510dc24e5f9", + user_id="5931a75ae4bbd512a88c680b", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceGroupUser.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_logger.py new file mode 100644 index 000000000000..7faf955347c6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_logger.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_logger.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_logger.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + logger_id="templateLogger", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceLogger.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_named_value.py new file mode 100644 index 000000000000..6384a4137daf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_named_value.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_named_value.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testarmTemplateproperties2", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceNamedValue.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_notification_recipient_email.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_notification_recipient_email.py new file mode 100644 index 000000000000..13c737a5f89d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_notification_recipient_email.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_notification_recipient_email.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification_recipient_email.check_entity_exists( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + email="contoso@live.com", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceNotificationRecipientEmail.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_notification_recipient_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_notification_recipient_user.py new file mode 100644 index 000000000000..1050e3261b30 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_notification_recipient_user.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_notification_recipient_user.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification_recipient_user.check_entity_exists( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + user_id="576823d0a40f7e74ec07d642", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceNotificationRecipientUser.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_policy.py new file mode 100644 index 000000000000..07e58a2417e1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_policy.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + policy_id="policy", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspacePolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_policy_fragment.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_policy_fragment.py new file mode 100644 index 000000000000..302f0bb17471 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_policy_fragment.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_policy_fragment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy_fragment.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + id="policyFragment1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspacePolicyFragment.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_product.py new file mode 100644 index 000000000000..494405fec5c8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_product.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_product.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="unlimited", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceProduct.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_product_policy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_product_policy.py new file mode 100644 index 000000000000..75c03a7e971f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_product_policy.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_product_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_policy.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="unlimited", + policy_id="policy", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceProductPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_schema.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_schema.py new file mode 100644 index 000000000000..cac3956f6a32 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_schema.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_schema.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_global_schema.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + schema_id="myschema", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceSchema.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_subscription.py new file mode 100644 index 000000000000..54734eae76b2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_subscription.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_subscription.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + sid="5931a769d8d14f0ad8ce13b8", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_tag.py new file mode 100644 index 000000000000..ee695a3dd1a1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_workspace_tag.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_head_workspace_tag.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag.get_entity_state( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="59306a29e4bbd510dc24e5f9", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementHeadWorkspaceTag.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_identity_provider_list_secrets.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_identity_provider_list_secrets.py index 2facc7fa8b1d..2c61ba5a9d37 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_identity_provider_list_secrets.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_identity_provider_list_secrets.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.identity_provider.list_secrets( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementIdentityProviderListSecrets.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementIdentityProviderListSecrets.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_diagnostics.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_diagnostics.py index d6c4afa765b8..ffb98fb842cb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_diagnostics.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_diagnostics.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_diagnostic.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiDiagnostics.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiDiagnostics.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issue_attachments.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issue_attachments.py index 028f3e5bb69f..229c5bb16392 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issue_attachments.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issue_attachments.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue_attachment.list_by_service( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiIssueAttachments.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiIssueAttachments.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issue_comments.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issue_comments.py index 0613ed9f7d33..2f7119b6ccd8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issue_comments.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issue_comments.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue_comment.list_by_service( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiIssueComments.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiIssueComments.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issues.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issues.py index 507dd5fb22d6..9c52af88bbfa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issues.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_issues.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiIssues.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiIssues.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operation_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operation_policies.py index 0a9a739bcd87..15d2f0ac8a42 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operation_policies.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operation_policies.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation_policy.list_by_operation( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiOperationPolicies.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiOperationPolicies.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operation_tags.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operation_tags.py index d723bb3acc6c..c662bd73644d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operation_tags.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operation_tags.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.list_by_operation( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiOperationTags.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiOperationTags.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operations.py index 4275c1480ef0..760158cd6824 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operations.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation.list_by_api( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiOperations.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiOperations.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operations_by_tags.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operations_by_tags.py index 2f23352f070a..e2e363cd800e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operations_by_tags.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_operations_by_tags.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.operation.list_by_tags( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiOperationsByTags.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiOperationsByTags.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_policies.py index 3516735fc869..881f468a7bab 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_policies.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_policies.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_policy.list_by_api( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiPolicies.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiPolicies.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_products.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_products.py index e3a930d3935f..7ea19cbca310 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_products.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_products.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_product.list_by_apis( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiProducts.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiProducts.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_releases.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_releases.py index 4b15b94f61f6..860929554af9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_releases.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_releases.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_release.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiReleases.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiReleases.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_revisions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_revisions.py index 2dfa6ea8936e..d20eb02a22d6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_revisions.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_revisions.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_revision.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiRevisions.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiRevisions.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_schemas.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_schemas.py index 24d01b4f258e..d984b64f21b7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_schemas.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_schemas.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_schema.list_by_api( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiSchemas.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiSchemas.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tag_descriptions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tag_descriptions.py index 7f53ed059ba6..c71d0f21a378 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tag_descriptions.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tag_descriptions.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_tag_description.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiTagDescriptions.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiTagDescriptions.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tags.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tags.py index 98a1c2650fcb..f71d1ad0fb65 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tags.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tags.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.list_by_api( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiTags.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiTags.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_version_sets.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_version_sets.py index a2f2e10543f8..178156cacaee 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_version_sets.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_version_sets.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_version_set.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiVersionSets.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiVersionSets.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_wikis.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_wikis.py index c7cb321df789..f0980528d894 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_wikis.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_wikis.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_wikis.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiWikis.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApiWikis.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_apis.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_apis.py index f9ba5a26426c..dd7f995a1965 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_apis.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_apis.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApis.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApis.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_apis_by_tags.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_apis_by_tags.py index f6c0cd1bf76e..82f17314d027 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_apis_by_tags.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_apis_by_tags.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.list_by_tags( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApisByTags.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListApisByTags.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_access_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_access_policies.py index ba363ea0c34a..28abb53eeb21 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_access_policies.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_access_policies.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_access_policy.list_by_authorization( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationAccessPolicies.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListAuthorizationAccessPolicies.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_providers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_providers.py index 93418ac79c06..b0cd6c028038 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_providers.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_providers.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_provider.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationProviders.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListAuthorizationProviders.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_servers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_servers.py index 4943108d1217..bf1c069be198 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_servers.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorization_servers.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_server.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationServers.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListAuthorizationServers.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorizations_auth_code.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorizations_auth_code.py index ad94b6768796..1a7b57611bca 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorizations_auth_code.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorizations_auth_code.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization.list_by_authorization_provider( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationsAuthCode.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListAuthorizationsAuthCode.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorizations_client_cred.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorizations_client_cred.py index b9c47bc05a41..be5d970b1857 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorizations_client_cred.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_authorizations_client_cred.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization.list_by_authorization_provider( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationsClientCred.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListAuthorizationsClientCred.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_backends.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_backends.py index 4fc8de14793b..ec376f89b73b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_backends.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_backends.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.backend.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListBackends.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListBackends.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_caches.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_caches.py index c864c34d5eb9..09d4b5d8f54b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_caches.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_caches.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.cache.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListCaches.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListCaches.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_certificates.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_certificates.py index 62fa790b46f6..f13a38f0f0e8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_certificates.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_certificates.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.certificate.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListCertificates.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListCertificates.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_content_type_content_items.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_content_type_content_items.py index ae309fcc4a3e..5f9023496cdb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_content_type_content_items.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_content_type_content_items.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.content_item.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListContentTypeContentItems.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListContentTypeContentItems.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_content_types.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_content_types.py index e142b2f6d775..3279ee707e21 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_content_types.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_content_types.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.content_type.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListContentTypes.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListContentTypes.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_diagnostics.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_diagnostics.py index 843a6f2ecaef..b7cef20fb6ad 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_diagnostics.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_diagnostics.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.diagnostic.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListDiagnostics.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListDiagnostics.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_documentations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_documentations.py index 043faf3f6374..2ccee819bdbd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_documentations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_documentations.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.documentation.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListDocumentations.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListDocumentations.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_apis.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_apis.py index b18adfe2501f..c83a10b97d6d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_apis.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_apis.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_api.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGatewayApis.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGatewayApis.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_certificate_authorities.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_certificate_authorities.py index aecf4e7e8b8c..94a481e6867c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_certificate_authorities.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_certificate_authorities.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_certificate_authority.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGatewayCertificateAuthorities.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGatewayCertificateAuthorities.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_config_connection.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_config_connection.py new file mode 100644 index 000000000000..0e7568e22a4a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_config_connection.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_gateway_config_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway_config_connection.list_by_gateway( + resource_group_name="rg1", + gateway_name="standard-gw-1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGatewayConfigConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_hostname_configurations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_hostname_configurations.py index 560f429c02c4..2846f6cb204a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_hostname_configurations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_hostname_configurations.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway_hostname_configuration.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGatewayHostnameConfigurations.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGatewayHostnameConfigurations.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways.py index 9a3f528f6656..effc91e36372 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGateways.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGateways.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways_by_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways_by_subscription.py new file mode 100644 index 000000000000..09b7fdd29218 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways_by_subscription.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_gateways_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGatewaysBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways_by_subscription_and_resource_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways_by_subscription_and_resource_group.py new file mode 100644 index 000000000000..0b172c808909 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateways_by_subscription_and_resource_group.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_gateways_by_subscription_and_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway.list_by_resource_group( + resource_group_name="rg1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGatewaysBySubscriptionAndResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_global_schemas.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_global_schemas.py index f5bfb7b8c982..b8e98e8a3ce9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_global_schemas.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_global_schemas.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.global_schema.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGlobalSchemas.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGlobalSchemas.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_graph_ql_api_resolver_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_graph_ql_api_resolver_policies.py index 6abd7a04e8c6..8f67ba35a5c3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_graph_ql_api_resolver_policies.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_graph_ql_api_resolver_policies.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver_policy.list_by_resolver( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGraphQLApiResolverPolicies.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGraphQLApiResolverPolicies.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_graph_ql_api_resolvers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_graph_ql_api_resolvers.py index 8897ad268cc5..0f420a1f3c4e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_graph_ql_api_resolvers.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_graph_ql_api_resolvers.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver.list_by_api( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGraphQLApiResolvers.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGraphQLApiResolvers.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_group_users.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_group_users.py index 4c021fed8439..52562fd43d50 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_group_users.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_group_users.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group_user.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGroupUsers.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGroupUsers.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_groups.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_groups.py index 661f1ec95acf..c906400ac5a8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_groups.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_groups.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGroups.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListGroups.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_identity_providers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_identity_providers.py index e9d72323e070..50052c247a9a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_identity_providers.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_identity_providers.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.identity_provider.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListIdentityProviders.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListIdentityProviders.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_issues.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_issues.py index 51f1d04ba246..1e55939fba4d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_issues.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_issues.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.issue.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListIssues.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListIssues.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_loggers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_loggers.py index f124c45afd6b..9e70acea7269 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_loggers.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_loggers.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.logger.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListLoggers.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListLoggers.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_named_values.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_named_values.py index 667b22252747..65314f102f98 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_named_values.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_named_values.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListNamedValues.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListNamedValues.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notification_recipient_emails.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notification_recipient_emails.py index a81cefe332df..d785e19f32bb 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notification_recipient_emails.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notification_recipient_emails.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification_recipient_email.list_by_notification( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListNotificationRecipientEmails.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListNotificationRecipientEmails.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notification_recipient_users.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notification_recipient_users.py index 857fdde80535..6b91c7c5706b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notification_recipient_users.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notification_recipient_users.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification_recipient_user.list_by_notification( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListNotificationRecipientUsers.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListNotificationRecipientUsers.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notifications.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notifications.py index c6e56444c48a..3df116302131 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notifications.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_notifications.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.notification.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListNotifications.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListNotifications.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_open_id_connect_providers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_open_id_connect_providers.py index dcc745d70599..5d3587e579ef 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_open_id_connect_providers.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_open_id_connect_providers.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.open_id_connect_provider.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListOpenIdConnectProviders.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListOpenIdConnectProviders.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_operations.py index 8e82f9843f5d..f33cf0205a6a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_operations.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListOperations.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListOperations.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policies.py index b30b3adebfca..d814d96f756d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policies.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policies.py @@ -27,16 +27,17 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy.list_by_service( resource_group_name="rg1", service_name="apimService1", ) - print(response) + for item in response: + print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPolicies.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPolicies.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_descriptions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_descriptions.py index eeec296c3f1d..4bda6d0194d9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_descriptions.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_descriptions.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy_description.list_by_service( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPolicyDescriptions.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPolicyDescriptions.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_fragment_references.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_fragment_references.py index 6b863fbd68d5..3556dfe87129 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_fragment_references.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_fragment_references.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy_fragment.list_references( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPolicyFragmentReferences.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPolicyFragmentReferences.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_fragments.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_fragments.py index 7b8cd130d0fc..e71c27975448 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_fragments.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_fragments.py @@ -27,16 +27,17 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.policy_fragment.list_by_service( resource_group_name="rg1", service_name="apimService1", ) - print(response) + for item in response: + print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPolicyFragments.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPolicyFragments.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_restrictions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_restrictions.py new file mode 100644 index 000000000000..977babe35895 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_policy_restrictions.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_policy_restrictions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.policy_restriction.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPolicyRestrictions.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_config.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_config.py index 3885112fca62..fd8ff108dddd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_config.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_config.py @@ -27,16 +27,17 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_config.list_by_service( resource_group_name="rg1", service_name="apimService1", ) - print(response) + for item in response: + print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPortalConfig.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPortalConfig.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_revisions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_revisions.py index 355335282beb..cd4e12c11ae5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_revisions.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_revisions.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_revision.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPortalRevisions.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPortalRevisions.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_settings.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_settings.py index bfc3ef7b3e5b..d90c0da2989c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_settings.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_portal_settings.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_settings.list_by_service( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPortalSettings.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPortalSettings.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_private_endpoint_connections.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_private_endpoint_connections.py index d722e2f97adf..07ad036411ad 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_private_endpoint_connections.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_private_endpoint_connections.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.private_endpoint_connection.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPrivateEndpointConnections.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPrivateEndpointConnections.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_private_link_group_resources.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_private_link_group_resources.py index 8b8351a061ce..e2921c60e7db 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_private_link_group_resources.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_private_link_group_resources.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.private_endpoint_connection.list_private_link_resources( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPrivateLinkGroupResources.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListPrivateLinkGroupResources.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_api_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_api_links.py new file mode 100644 index 000000000000..6fe40194c20c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_api_links.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_product_api_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.product_api_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + product_id="product1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductApiLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_apis.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_apis.py index 477e31e770f2..42ea3f3a92a2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_apis.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_apis.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_api.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductApis.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductApis.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_group_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_group_links.py new file mode 100644 index 000000000000..1da1640bd295 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_group_links.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_product_group_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.product_group_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + product_id="product1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductGroupLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_groups.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_groups.py index 01ba6e480e8d..5c52415d704a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_groups.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_groups.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_group.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductGroups.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductGroups.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_policies.py index bff1ec50602a..4ee3d5201dc6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_policies.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_policies.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_policy.list_by_product( @@ -35,9 +35,10 @@ def main(): service_name="apimService1", product_id="armTemplateProduct4", ) - print(response) + for item in response: + print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductPolicies.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductPolicies.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_subscriptions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_subscriptions.py index 1d807a54e9fe..2daf7d9989b2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_subscriptions.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_subscriptions.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_subscriptions.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductSubscriptions.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductSubscriptions.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_tags.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_tags.py index 710eeb77155e..34e68c2e9977 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_tags.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_tags.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductTags.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductTags.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_wikis.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_wikis.py index 581fc5edceaf..5b9114df70cf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_wikis.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_product_wikis.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_wikis.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductWikis.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductWikis.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_products.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_products.py index 22fb48f53ec8..d6c5663f07d1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_products.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_products.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProducts.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProducts.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_products_by_tags.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_products_by_tags.py index 5a9b7fb28701..a91341b33fed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_products_by_tags.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_products_by_tags.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product.list_by_tags( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductsByTags.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListProductsByTags.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_regions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_regions.py index 4e3232ae12e3..bc7f890b3f54 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_regions.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_regions.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.region.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListRegions.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListRegions.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_secrets_portal_settings_validation_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_secrets_portal_settings_validation_key.py index 75a8d6c38bba..a785901281e5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_secrets_portal_settings_validation_key.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_secrets_portal_settings_validation_key.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.delegation_settings.list_secrets( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSecretsPortalSettingsValidationKey.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListSecretsPortalSettingsValidationKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_secrets_tenant_access.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_secrets_tenant_access.py index 8682f45bccd8..e32488550a24 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_secrets_tenant_access.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_secrets_tenant_access.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_access.list_secrets( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSecretsTenantAccess.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListSecretsTenantAccess.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_service_by_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_service_by_subscription.py index a9d5afd6db14..13f3a75f4367 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_service_by_subscription.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_service_by_subscription.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.list() @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListServiceBySubscription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListServiceBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_service_by_subscription_and_resource_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_service_by_subscription_and_resource_group.py index 3f4c2440800f..18a7be4cdc1f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_service_by_subscription_and_resource_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_service_by_subscription_and_resource_group.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.list_by_resource_group( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListServiceBySubscriptionAndResourceGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListServiceBySubscriptionAndResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_consumption.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_consumption.py index d06fb654424c..57788bef08ea 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_consumption.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_consumption.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service_skus.list_available_service_skus( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSKUs-Consumption.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListSKUs-Consumption.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_dedicated.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_dedicated.py index b3e7739ec54f..b00802134714 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_dedicated.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_dedicated.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service_skus.list_available_service_skus( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSKUs-Dedicated.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListSKUs-Dedicated.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_gateways.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_gateways.py new file mode 100644 index 000000000000..91daf370898a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sk_us_gateways.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_sk_us_gateways.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_management_gateway_skus.list_available_skus( + resource_group_name="rg1", + gateway_name="apimService1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListSKUs-Gateways.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sku.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sku.py index 06fb9533d258..0b6721f49fb2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sku.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_sku.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_skus.list() @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSku.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListSku.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_subscriptions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_subscriptions.py index 02487b52d022..9243a4c38c6e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_subscriptions.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_subscriptions.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.subscription.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSubscriptions.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListSubscriptions.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_api_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_api_links.py new file mode 100644 index 000000000000..e21fec6b2c08 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_api_links.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_tag_api_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_api_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListTagApiLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_operation_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_operation_links.py new file mode 100644 index 000000000000..86498548aeb4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_operation_links.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_tag_operation_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_operation_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListTagOperationLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_product_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_product_links.py new file mode 100644 index 000000000000..414e8430e5c1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_product_links.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_tag_product_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.tag_product_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + tag_id="tag1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListTagProductLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_resources.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_resources.py index 579d68457051..2f3d3092e678 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_resources.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tag_resources.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag_resource.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTagResources.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListTagResources.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tags.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tags.py index 91997d0255df..ee269d796ea3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tags.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tags.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTags.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListTags.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_templates.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_templates.py index 234d61d90900..c8c10f7a53e6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_templates.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_templates.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.email_template.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTemplates.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListTemplates.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tenant_access.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tenant_access.py index 221c8e8cde75..13045b9108e9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tenant_access.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tenant_access.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_access.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTenantAccess.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListTenantAccess.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tenant_settings.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tenant_settings.py index 85bf6cadb679..3b49374f335e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tenant_settings.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_tenant_settings.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_settings.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTenantSettings.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListTenantSettings.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_groups.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_groups.py index 25d259a6dce7..943cfefbc704 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_groups.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_groups.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user_group.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListUserGroups.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListUserGroups.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_identities.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_identities.py index 5252b1600ef7..0c74387f8ebc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_identities.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_identities.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user_identities.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListUserIdentities.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListUserIdentities.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_subscriptions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_subscriptions.py index d3dd965a0c6d..676add910f67 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_subscriptions.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_user_subscriptions.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user_subscription.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListUserSubscriptions.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListUserSubscriptions.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_users.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_users.py index 9f381fda1fae..60d63921377c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_users.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_users.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListUsers.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListUsers.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_diagnostics.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_diagnostics.py new file mode 100644 index 000000000000..f605ecb40170 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_diagnostics.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_api_diagnostics.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_diagnostic.list_by_workspace( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="echo-api", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApiDiagnostics.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_operation_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_operation_policies.py new file mode 100644 index 000000000000..74017af790ae --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_operation_policies.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_api_operation_policies.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation_policy.list_by_operation( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="599e2953193c3c0bd0b3e2fa", + operation_id="599e29ab193c3c0bd0b3e2fb", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApiOperationPolicies.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_operations.py new file mode 100644 index 000000000000..2887a91fa048 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_operations.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_api_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation.list_by_api( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d2ef278aa04f0888cba3f3", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApiOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_policies.py new file mode 100644 index 000000000000..5665972f504a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_policies.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_api_policies.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_policy.list_by_api( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="5600b59475ff190048040001", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApiPolicies.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_releases.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_releases.py new file mode 100644 index 000000000000..5bf5d8d182c8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_releases.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_api_releases.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_release.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="a1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApiReleases.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_revisions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_revisions.py new file mode 100644 index 000000000000..517322175810 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_revisions.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_api_revisions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_revision.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="57d2ef278aa04f0888cba3f3", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApiRevisions.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_schemas.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_schemas.py new file mode 100644 index 000000000000..4e37461b8bef --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_schemas.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_api_schemas.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_schema.list_by_api( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="59d5b28d1f7fab116c282650", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApiSchemas.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_version_sets.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_version_sets.py new file mode 100644 index 000000000000..39a2ae3ef1c9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_api_version_sets.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_api_version_sets.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_version_set.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApiVersionSets.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_apis.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_apis.py new file mode 100644 index 000000000000..ef6d1b30327c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_apis.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_apis.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceApis.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_backends.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_backends.py new file mode 100644 index 000000000000..cc04873fe9e5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_backends.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_backends.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_backend.list_by_workspace( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceBackends.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_certificates.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_certificates.py new file mode 100644 index 000000000000..c411bb82d7d7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_certificates.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_certificates.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_certificate.list_by_workspace( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceCertificates.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_diagnostics.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_diagnostics.py new file mode 100644 index 000000000000..e7a0fdb45832 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_diagnostics.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_diagnostics.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_diagnostic.list_by_workspace( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceDiagnostics.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_group_users.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_group_users.py new file mode 100644 index 000000000000..c3983779ba45 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_group_users.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_group_users.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group_user.list( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="57d2ef278aa04f0888cba3f3", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceGroupUsers.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_groups.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_groups.py new file mode 100644 index 000000000000..7d1c6e228019 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_groups.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_groups.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceGroups.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_links.py new file mode 100644 index 000000000000..2e721bebdfaf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_links.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_management_workspace_links.list_by_service( + resource_group_name="rg1", + service_name="service1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_loggers.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_loggers.py new file mode 100644 index 000000000000..981cfe552a45 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_loggers.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_loggers.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_logger.list_by_workspace( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceLoggers.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_named_values.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_named_values.py new file mode 100644 index 000000000000..16b32fd7e7af --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_named_values.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_named_values.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceNamedValues.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notification_recipient_emails.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notification_recipient_emails.py new file mode 100644 index 000000000000..1f7b3bab23f4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notification_recipient_emails.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_notification_recipient_emails.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification_recipient_email.list_by_notification( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceNotificationRecipientEmails.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notification_recipient_users.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notification_recipient_users.py new file mode 100644 index 000000000000..2dd0dc25bbc2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notification_recipient_users.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_notification_recipient_users.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification_recipient_user.list_by_notification( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + notification_name="RequestPublisherNotificationMessage", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceNotificationRecipientUsers.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notifications.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notifications.py new file mode 100644 index 000000000000..170220b67647 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_notifications.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_notifications.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_notification.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceNotifications.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policies.py new file mode 100644 index 000000000000..cd7840374072 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policies.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_policies.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy.list_by_api( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspacePolicies.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policy_fragment_references.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policy_fragment_references.py new file mode 100644 index 000000000000..ff81fb43184b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policy_fragment_references.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_policy_fragment_references.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy_fragment.list_references( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + id="policyFragment1", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspacePolicyFragmentReferences.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policy_fragments.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policy_fragments.py new file mode 100644 index 000000000000..610064ebe476 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_policy_fragments.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_policy_fragments.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_policy_fragment.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspacePolicyFragments.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_api_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_api_links.py new file mode 100644 index 000000000000..3651e3f0730a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_api_links.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_product_api_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_api_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="product1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceProductApiLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_group_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_group_links.py new file mode 100644 index 000000000000..a109366a1392 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_group_links.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_product_group_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_group_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="product1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceProductGroupLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_policies.py new file mode 100644 index 000000000000..b6679bae3f3a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_product_policies.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_product_policies.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product_policy.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="armTemplateProduct4", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceProductPolicies.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_products.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_products.py new file mode 100644 index 000000000000..e839eafce723 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_products.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_products.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceProducts.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_schemas.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_schemas.py new file mode 100644 index 000000000000..ede5d7023d90 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_schemas.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_schemas.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_global_schema.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceSchemas.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_subscriptions.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_subscriptions.py new file mode 100644 index 000000000000..d916437642cb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_subscriptions.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_subscriptions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_subscription.list( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceSubscriptions.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_api_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_api_links.py new file mode 100644 index 000000000000..120d84df4802 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_api_links.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_tag_api_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_api_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceTagApiLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_operation_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_operation_links.py new file mode 100644 index 000000000000..13c3458e3e04 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_operation_links.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_tag_operation_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_operation_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceTagOperationLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_product_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_product_links.py new file mode 100644 index 000000000000..be5da5dc3f27 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tag_product_links.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_tag_product_links.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag_product_link.list_by_product( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="tag1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceTagProductLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tags.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tags.py new file mode 100644 index 000000000000..1885a74a40e7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspace_tags.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspace_tags.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaceTags.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspaces.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspaces.py new file mode 100644 index 000000000000..4a65efb3ab06 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_workspaces.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_list_workspaces.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementListWorkspaces.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_named_value_list_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_named_value_list_value.py index ee150813cbe9..69b18e757476 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_named_value_list_value.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_named_value_list_value.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.list_value( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementNamedValueListValue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementNamedValueListValue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_openid_connect_provider_list_secrets.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_openid_connect_provider_list_secrets.py index bfbd905300d1..85208b70a898 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_openid_connect_provider_list_secrets.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_openid_connect_provider_list_secrets.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.open_id_connect_provider.list_secrets( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementOpenidConnectProviderListSecrets.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementOpenidConnectProviderListSecrets.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_perform_connectivity_check.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_perform_connectivity_check.py index a00b17845dfb..4188d61af972 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_perform_connectivity_check.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_perform_connectivity_check.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.begin_perform_connectivity_check_async( @@ -44,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPerformConnectivityCheck.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPerformConnectivityCheck.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_perform_connectivity_check_http_connect.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_perform_connectivity_check_http_connect.py index cffdc12330b1..94e582b8ca13 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_perform_connectivity_check_http_connect.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_perform_connectivity_check_http_connect.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.begin_perform_connectivity_check_async( @@ -40,7 +38,7 @@ def main(): "protocol": "HTTPS", "protocolConfiguration": { "HTTPConfiguration": { - "headers": [{"name": "Authorization", "value": "******"}], + "headers": [{"name": "Authorization", "value": "Bearer myPreciousToken"}], "method": "GET", "validStatusCodes": [200, 204], } @@ -51,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPerformConnectivityCheckHttpConnect.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPerformConnectivityCheckHttpConnect.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_config.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_config.py index 568b208200a4..80aa0f2089a1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_config.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_config.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_config.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalConfig.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalConfig.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_delegation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_delegation.py index 66df4dc06092..a47d217dd156 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_delegation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_delegation.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.delegation_settings.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsGetDelegation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsGetDelegation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_sign_in.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_sign_in.py index 3c9c2cc22fe7..23469eb6bcb1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_sign_in.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_sign_in.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.sign_in_settings.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsGetSignIn.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsGetSignIn.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_sign_up.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_sign_up.py index 86c8505d0d81..26537a37446a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_sign_up.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_get_sign_up.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.sign_up_settings.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsGetSignUp.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsGetSignUp.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_delegation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_delegation.py index bd3604e4d281..4987cf779398 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_delegation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_delegation.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.delegation_settings.create_or_update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsPutDelegation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsPutDelegation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_sign_in.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_sign_in.py index 5201e8aeee9f..fc31cb93e7f9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_sign_in.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_sign_in.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.sign_in_settings.create_or_update( @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsPutSignIn.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsPutSignIn.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_sign_up.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_sign_up.py index 9f5e9b15ff25..c3f7003698bc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_sign_up.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_put_sign_up.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.sign_up_settings.create_or_update( @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsPutSignUp.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsPutSignUp.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_delegation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_delegation.py index ea3c96d72e5d..95ff241b650a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_delegation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_delegation.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.delegation_settings.update( @@ -47,6 +45,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsUpdateDelegation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsUpdateDelegation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_sign_in.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_sign_in.py index f913bc93247d..e213f377a989 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_sign_in.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_sign_in.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.sign_in_settings.update( @@ -40,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsUpdateSignIn.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsUpdateSignIn.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_sign_up.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_sign_up.py index 69879e9eca16..5660a72dd8d9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_sign_up.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_portal_settings_update_sign_up.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.sign_up_settings.update( @@ -45,6 +43,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsUpdateSignUp.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPortalSettingsUpdateSignUp.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_post_authorization_confirm_consent_code_request.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_post_authorization_confirm_consent_code_request.py index 328d4118b451..5006bb51096d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_post_authorization_confirm_consent_code_request.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_post_authorization_confirm_consent_code_request.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.authorization.confirm_consent_code( @@ -41,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPostAuthorizationConfirmConsentCodeRequest.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementPostAuthorizationConfirmConsentCodeRequest.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_certificate.py index 71ef66240ab9..51bdaca868f0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_certificate.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_certificate.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.certificate.refresh_secret( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementRefreshCertificate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementRefreshCertificate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_named_value.py index 196df23c39fd..bc6f0268a645 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_named_value.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_named_value.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.begin_refresh_secret( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementRefreshNamedValue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementRefreshNamedValue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_workspace_certificate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_workspace_certificate.py new file mode 100644 index 000000000000..36693d410a60 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_workspace_certificate.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_refresh_workspace_certificate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_certificate.refresh_secret( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + certificate_id="templateCertkv", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementRefreshWorkspaceCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_workspace_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_workspace_named_value.py new file mode 100644 index 000000000000..7aca1ac96584 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_workspace_named_value.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_refresh_workspace_named_value.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.begin_refresh_secret( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testprop2", + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementRefreshWorkspaceNamedValue.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_restore_with_access_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_restore_with_access_key.py index 62b9421f8b7b..ccac08706bf9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_restore_with_access_key.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_restore_with_access_key.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_restore( @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementRestoreWithAccessKey.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementRestoreWithAccessKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_check_name_availability.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_check_name_availability.py index 785a1a061d70..7286f4ea05f2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_check_name_availability.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_check_name_availability.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.check_name_availability( @@ -38,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceCheckNameAvailability.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_delete_service.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_delete_service.py index c32838512adb..e73e3b52b3f8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_delete_service.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_delete_service.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_delete( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceDeleteService.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceDeleteService.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_domain_ownership_identifier.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_domain_ownership_identifier.py index cfe6ebb855fd..b5a5db6650d7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_domain_ownership_identifier.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_domain_ownership_identifier.py @@ -27,13 +27,13 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.get_domain_ownership_identifier() print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetDomainOwnershipIdentifier.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceGetDomainOwnershipIdentifier.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_multi_region_internal_vnet.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_multi_region_internal_vnet.py index 0286e7688534..4db7eff0b017 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_multi_region_internal_vnet.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_multi_region_internal_vnet.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetMultiRegionInternalVnet.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceGetMultiRegionInternalVnet.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_network_status.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_network_status.py index 19fb9e874cbe..64cae9017d3f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_network_status.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_network_status.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.network_status.list_by_service( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetNetworkStatus.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceGetNetworkStatus.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_network_status_by_location.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_network_status_by_location.py index db1a19e8aecb..d608a7d4e951 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_network_status_by_location.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_network_status_by_location.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.network_status.list_by_location( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetNetworkStatusByLocation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceGetNetworkStatusByLocation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_outbound_network_dependencies_endpoints.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_outbound_network_dependencies_endpoints.py index 2ef99964f378..9e4d021702a4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_outbound_network_dependencies_endpoints.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_outbound_network_dependencies_endpoints.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.outbound_network_dependencies_endpoints.list_by_service( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetOutboundNetworkDependenciesEndpoints.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceGetOutboundNetworkDependenciesEndpoints.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_service.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_service.py index 4b348f451501..030d2ccb4b9d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_service.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_service.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetService.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceGetService.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_service_having_msi.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_service_having_msi.py index f71ada140d68..a30669de6cea 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_service_having_msi.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_service_having_msi.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetServiceHavingMsi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceGetServiceHavingMsi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_sso_token.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_sso_token.py index d18ef5c92432..b5422a8abb7a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_sso_token.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_get_sso_token.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.get_sso_token( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetSsoToken.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceGetSsoToken.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_migrate_to_stv2.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_migrate_to_stv2.py index 0e114621f095..b3f2d5768823 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_migrate_to_stv2.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_migrate_to_stv2.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_migrate_to_stv2( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceMigrateToStv2.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementServiceMigrateToStv2.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_list_secrets.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_list_secrets.py index f5c18fc448cc..5ce3e89d601c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_list_secrets.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_list_secrets.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.subscription.list_secrets( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementSubscriptionListSecrets.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementSubscriptionListSecrets.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_regenerate_primary_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_regenerate_primary_key.py index fa5212a2d339..1cef3e600151 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_regenerate_primary_key.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_regenerate_primary_key.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.subscription.regenerate_primary_key( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementSubscriptionRegeneratePrimaryKey.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementSubscriptionRegeneratePrimaryKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_regenerate_secondary_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_regenerate_secondary_key.py index 7ebcded6051f..d1ac4fa923e2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_regenerate_secondary_key.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_subscription_regenerate_secondary_key.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.subscription.regenerate_secondary_key( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementSubscriptionRegenerateSecondaryKey.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementSubscriptionRegenerateSecondaryKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_key.py index c23d7ebb6c38..ace209e6f0fc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_key.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_key.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,16 +27,16 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - client.tenant_access.regenerate_primary_key( + client.tenant_access_git.regenerate_secondary_key( resource_group_name="rg1", service_name="apimService1", access_name="access", ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantAccessRegenerateKey.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementTenantAccessRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_sync_state.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_sync_state.py index 38c4303f235e..442274d69efa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_sync_state.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_sync_state.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_configuration.get_sync_state( @@ -43,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantAccessSyncState.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementTenantAccessSyncState.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_deploy.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_deploy.py index a17270a566d3..5f9a4f15cd1b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_deploy.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_deploy.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_configuration.begin_deploy( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantConfigurationDeploy.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementTenantConfigurationDeploy.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_save.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_save.py index df73ed1b62c8..9eaab172eb15 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_save.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_save.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_configuration.begin_save( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantConfigurationSave.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementTenantConfigurationSave.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_validate.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_validate.py index 425a450ba2aa..0fadbc39cc3a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_validate.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_configuration_validate.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_configuration.begin_validate( @@ -44,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantConfigurationValidate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementTenantConfigurationValidate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_undelete.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_undelete.py index 93b98fb0578b..d6b92ceff93b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_undelete.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_undelete.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_create_or_update( @@ -44,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUndelete.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUndelete.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api.py index b62387ff8821..74d99bac1618 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api.update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApi.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateApi.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_diagnostic.py index 2dec0448301d..604d6620187c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_diagnostic.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_diagnostic.update( @@ -57,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateApiDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_issue.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_issue.py index 0309355512f9..1808b0a5bb87 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_issue.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_issue.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_issue.update( @@ -43,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiIssue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateApiIssue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_operation.py index 1cad1761aafe..7a2fa73e91af 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_operation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_operation.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_operation.update( @@ -66,6 +64,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiOperation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateApiOperation.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_release.py index a05713216f09..1ff9088fc7fc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_release.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_release.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_release.update( @@ -40,7 +38,7 @@ def main(): if_match="*", parameters={ "properties": { - "apiId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1", + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1", "notes": "yahooagain", } }, @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiRelease.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateApiRelease.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_version_set.py index f89a94dd896d..04eba5fc9d59 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_version_set.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_version_set.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_version_set.update( @@ -48,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiVersionSet.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateApiVersionSet.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_wiki.py index 41b37f6ef724..792323034a49 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_wiki.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_wiki.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateApiWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_authorization_server.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_authorization_server.py index 2df826b576f2..c8d232c84913 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_authorization_server.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_authorization_server.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.authorization_server.update( @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateAuthorizationServer.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateAuthorizationServer.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_backend.py index f2fff34cdfe5..71fcce734f88 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_backend.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_backend.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.backend.update( @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateBackend.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateBackend.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_cache.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_cache.py index f79f8bddb287..078e7d4f7ece 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_cache.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_cache.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.cache.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateCache.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateCache.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_diagnostic.py index 63676dc5cf4e..7b971e98d434 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_diagnostic.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_diagnostic.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.diagnostic.update( @@ -56,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateDiagnostic.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateDiagnostic.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_gateway.py index 053bb01128cf..f3f7e78207f8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_gateway.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_gateway.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.gateway.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateGateway.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateGateway.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_graph_ql_api_resolver.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_graph_ql_api_resolver.py index 98a4a2a40682..514061fa805b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_graph_ql_api_resolver.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_graph_ql_api_resolver.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.graph_ql_api_resolver.update( @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateGraphQLApiResolver.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateGraphQLApiResolver.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_group.py index f6aad0a5b93a..de1e29e015ec 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_group.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_group.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.group.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateGroup.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateGroup.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_identity_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_identity_provider.py index b809574021ec..9e0656f27385 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_identity_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_identity_provider.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.identity_provider.update( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateIdentityProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateIdentityProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_logger.py index 43e8b40b5055..4c8210982f99 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_logger.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_logger.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.logger.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateLogger.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateLogger.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_named_value.py index 41f520132d27..93eff38db50a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_named_value.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_named_value.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.named_value.begin_update( @@ -44,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateNamedValue.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateNamedValue.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_open_id_connect_provider.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_open_id_connect_provider.py index 7caf92e028e4..885cb5b72843 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_open_id_connect_provider.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_open_id_connect_provider.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.open_id_connect_provider.update( @@ -44,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateOpenIdConnectProvider.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateOpenIdConnectProvider.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_policy_restriction.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_policy_restriction.py new file mode 100644 index 000000000000..f2856018c21f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_policy_restriction.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_policy_restriction.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.policy_restriction.update( + resource_group_name="rg1", + service_name="apimService1", + policy_restriction_id="policyRestriction1", + if_match="*", + parameters={"properties": {"scope": "Sample Path 2 to the policy document."}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdatePolicyRestriction.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_portal_config.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_portal_config.py index a14363c85eef..059a32f8b644 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_portal_config.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_portal_config.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_config.update( @@ -62,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdatePortalConfig.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdatePortalConfig.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_portal_revision.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_portal_revision.py index 0db619110fb6..67e8c12aed82 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_portal_revision.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_portal_revision.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.portal_revision.begin_update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdatePortalRevision.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdatePortalRevision.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_product.py index 5e850cf34b59..cc17c4790547 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_product.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_product.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateProduct.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateProduct.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_product_wiki.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_product_wiki.py index cbbb850f1197..1500a07094d1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_product_wiki.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_product_wiki.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.product_wiki.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateProductWiki.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateProductWiki.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_quota_counter_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_quota_counter_key.py index ac1e33c817f2..259718ebfbc9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_quota_counter_key.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_quota_counter_key.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.quota_by_counter_keys.update( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateQuotaCounterKey.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateQuotaCounterKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_quota_counter_key_by_quota_period.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_quota_counter_key_by_quota_period.py index 5fd6073a3122..eeb453e9f1be 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_quota_counter_key_by_quota_period.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_quota_counter_key_by_quota_period.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.quota_by_period_keys.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateQuotaCounterKeyByQuotaPeriod.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateQuotaCounterKeyByQuotaPeriod.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_disable_tls10.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_disable_tls10.py index 1aaa74b23e27..3f47fcbf5b3a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_disable_tls10.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_disable_tls10.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_update( @@ -44,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateServiceDisableTls10.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateServiceDisableTls10.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_publisher_details.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_publisher_details.py index 1c62a6e4f282..90297eff7dd1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_publisher_details.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_publisher_details.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_update( @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateServicePublisherDetails.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateServicePublisherDetails.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_to_new_vnet_and_azs.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_to_new_vnet_and_azs.py index 7e8ead831050..a76bd5ae038e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_to_new_vnet_and_azs.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_service_to_new_vnet_and_azs.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.api_management_service.begin_update( @@ -40,17 +38,17 @@ def main(): "additionalLocations": [ { "location": "Australia East", - "publicIpAddressId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/apim-australia-east-publicip", + "publicIpAddressId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/apim-australia-east-publicip", "sku": {"capacity": 3, "name": "Premium"}, "virtualNetworkConfiguration": { - "subnetResourceId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/apimaeavnet/subnets/default" + "subnetResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/apimaeavnet/subnets/default" }, "zones": ["1", "2", "3"], } ], - "publicIpAddressId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/publicip-apim-japan-east", + "publicIpAddressId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/publicip-apim-japan-east", "virtualNetworkConfiguration": { - "subnetResourceId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-apim-japaneast/subnets/apim2" + "subnetResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-apim-japaneast/subnets/apim2" }, "virtualNetworkType": "External", }, @@ -61,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateServiceToNewVnetAndAZs.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateServiceToNewVnetAndAZs.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_standard_gateway.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_standard_gateway.py new file mode 100644 index 000000000000..99e05ae59631 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_standard_gateway.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_standard_gateway.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.api_gateway.begin_update( + resource_group_name="rg1", + gateway_name="apimGateway1", + parameters={ + "properties": {}, + "sku": {"capacity": 10, "name": "Standard"}, + "tags": {"Name": "Contoso", "Test": "User"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateStandardGateway.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_subscription.py index 9a90e26e9643..df1723e5f336 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_subscription.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_subscription.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.subscription.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateSubscription.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateSubscription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_tag.py index b483ffebed26..d79a8192afe7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_tag.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_tag.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tag.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateTag.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateTag.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_template.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_template.py index 1ab5da896e91..799e4ca59a43 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_template.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_template.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.email_template.update( @@ -50,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateTemplate.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateTemplate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_tenant_access.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_tenant_access.py index 793ea5bfe6fe..ad78dbb67f76 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_tenant_access.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_tenant_access.py @@ -6,15 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, TYPE_CHECKING, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -32,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.tenant_access.update( @@ -45,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateTenantAccess.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateTenantAccess.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_user.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_user.py index 20dd7fbfd2da..b51b76997c9c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_user.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_user.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user.update( @@ -42,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateUser.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_documentation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace.py similarity index 77% rename from sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_documentation.py rename to sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace.py index 577231e635df..d4f6dedecc97 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_documentation.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -17,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-apimanagement # USAGE - python api_management_update_documentation.py + python api_management_update_workspace.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,19 +27,19 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.documentation.update( + response = client.workspace.update( resource_group_name="rg1", service_name="apimService1", - documentation_id="57d1f7558aa04f15146d9d8a", + workspace_id="wks1", if_match="*", - parameters={"properties": {"content": "content updated", "title": "Title updated"}}, + parameters={"properties": {"description": "workspace 1", "displayName": "my workspace"}}, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateDocumentation.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspace.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api.py new file mode 100644 index 000000000000..92852137d148 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="echo-api", + if_match="*", + parameters={ + "properties": { + "displayName": "Echo API New", + "path": "newecho", + "serviceUrl": "http://echoapi.cloudapp.net/api2", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceApi.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_diagnostic.py new file mode 100644 index 000000000000..d5ee8a309557 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_diagnostic.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_api_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_diagnostic.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="echo-api", + diagnostic_id="applicationinsights", + if_match="*", + parameters={ + "properties": { + "alwaysLog": "allErrors", + "backend": { + "request": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + "response": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + }, + "frontend": { + "request": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + "response": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + }, + "loggerId": "/workspaces/wks1/loggers/applicationinsights", + "sampling": {"percentage": 50, "samplingType": "fixed"}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceApiDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_operation.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_operation.py new file mode 100644 index 000000000000..f9cac3a0cfb3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_operation.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_api_operation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_operation.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="echo-api", + operation_id="operationId", + if_match="*", + parameters={ + "properties": { + "displayName": "Retrieve resource", + "method": "GET", + "request": { + "queryParameters": [ + { + "defaultValue": "sample", + "description": 'A sample parameter that is required and has a default value of "sample".', + "name": "param1", + "required": True, + "type": "string", + "values": ["sample"], + } + ] + }, + "responses": [ + {"description": "Returned in all cases.", "headers": [], "representations": [], "statusCode": 200}, + {"description": "Server Error.", "headers": [], "representations": [], "statusCode": 500}, + ], + "templateParameters": [], + "urlTemplate": "/resource", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceApiOperation.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_release.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_release.py new file mode 100644 index 000000000000..77dc5db61ed5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_release.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_api_release.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_release.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + api_id="a1", + release_id="testrev", + if_match="*", + parameters={ + "properties": { + "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/a1", + "notes": "yahooagain", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceApiRelease.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_version_set.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_version_set.py new file mode 100644 index 000000000000..2e34b57a0ead --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_api_version_set.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_api_version_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_api_version_set.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + version_set_id="vs1", + if_match="*", + parameters={ + "properties": { + "description": "Version configuration", + "displayName": "api set 1", + "versioningScheme": "Segment", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceApiVersionSet.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_backend.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_backend.py new file mode 100644 index 000000000000..a1f954152945 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_backend.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_backend.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_backend.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + backend_id="proxybackend", + if_match="*", + parameters={ + "properties": { + "description": "description5308", + "tls": {"validateCertificateChain": False, "validateCertificateName": True}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceBackend.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_diagnostic.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_diagnostic.py new file mode 100644 index 000000000000..5cd5724bf221 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_diagnostic.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_diagnostic.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_diagnostic.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + diagnostic_id="applicationinsights", + if_match="*", + parameters={ + "properties": { + "alwaysLog": "allErrors", + "backend": { + "request": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + "response": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + }, + "frontend": { + "request": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + "response": {"body": {"bytes": 512}, "headers": ["Content-type"]}, + }, + "loggerId": "/workspaces/wks1/loggers/applicationinsights", + "sampling": {"percentage": 50, "samplingType": "fixed"}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceDiagnostic.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_group.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_group.py new file mode 100644 index 000000000000..05ba2d60b991 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_group.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_group.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + group_id="tempgroup", + if_match="*", + parameters={"properties": {"displayName": "temp group"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_logger.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_logger.py new file mode 100644 index 000000000000..8c9a5838d80b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_logger.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_logger.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_logger.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + logger_id="eh1", + if_match="*", + parameters={"properties": {"description": "updating description", "loggerType": "azureEventHub"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceLogger.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_named_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_named_value.py new file mode 100644 index 000000000000..3d3f8242e784 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_named_value.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_named_value.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.begin_update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testprop2", + if_match="*", + parameters={ + "properties": {"displayName": "prop3name", "secret": False, "tags": ["foo", "bar2"], "value": "propValue"} + }, + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceNamedValue.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_product.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_product.py new file mode 100644 index 000000000000..44d03d1e6070 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_product.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_product.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_product.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + product_id="testproduct", + if_match="*", + parameters={"properties": {"displayName": "Test Template ProductName 4"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceProduct.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_subscription.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_subscription.py new file mode 100644 index 000000000000..c6add6dfda93 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_subscription.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_subscription.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + sid="testsub", + if_match="*", + parameters={"properties": {"displayName": "testsub"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_tag.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_tag.py new file mode 100644 index 000000000000..1683f34a8124 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace_tag.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_update_workspace_tag.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_tag.update( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + tag_id="temptag", + if_match="*", + parameters={"properties": {"displayName": "temp tag"}}, + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUpdateWorkspaceTag.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_confirmation_password_send.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_confirmation_password_send.py index 3a602061d599..817451c2b0f9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_confirmation_password_send.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_confirmation_password_send.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) client.user_confirmation_password.send( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUserConfirmationPasswordSend.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUserConfirmationPasswordSend.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_generate_sso_url.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_generate_sso_url.py index f5075a26f8f9..f72d3f1b2e95 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_generate_sso_url.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_generate_sso_url.py @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user.generate_sso_url( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUserGenerateSsoUrl.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUserGenerateSsoUrl.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_token.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_token.py index 83df805dfc9c..243041963f02 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_token.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_user_token.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.apimanagement import ApiManagementClient @@ -29,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.user.get_shared_access_token( @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUserToken.json +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementUserToken.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_validate_policies.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_validate_policies.py new file mode 100644 index 000000000000..2909b17d2fd9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_validate_policies.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_validate_policies.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.policy_restriction_validations.begin_by_service( + resource_group_name="rg1", + service_name="apimService1", + ).result() + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementValidatePolicies.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_named_value_list_value.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_named_value_list_value.py new file mode 100644 index 000000000000..d55d2535ce20 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_named_value_list_value.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_workspace_named_value_list_value.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_named_value.list_value( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + named_value_id="testarmTemplateproperties2", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementWorkspaceNamedValueListValue.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_list_secrets.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_list_secrets.py new file mode 100644 index 000000000000..e21a44399cb9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_list_secrets.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_workspace_subscription_list_secrets.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.workspace_subscription.list_secrets( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + sid="5931a769d8d14f0ad8ce13b8", + ) + print(response) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementWorkspaceSubscriptionListSecrets.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_regenerate_primary_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_regenerate_primary_key.py new file mode 100644 index 000000000000..8b33e36fade6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_regenerate_primary_key.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_workspace_subscription_regenerate_primary_key.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_subscription.regenerate_primary_key( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + sid="testsub", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementWorkspaceSubscriptionRegeneratePrimaryKey.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_regenerate_secondary_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_regenerate_secondary_key.py new file mode 100644 index 000000000000..89a56b847667 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_workspace_subscription_regenerate_secondary_key.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.apimanagement import ApiManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-apimanagement +# USAGE + python api_management_workspace_subscription_regenerate_secondary_key.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ApiManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.workspace_subscription.regenerate_secondary_key( + resource_group_name="rg1", + service_name="apimService1", + workspace_id="wks1", + sid="testsub", + ) + + +# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-09-01/examples/ApiManagementWorkspaceSubscriptionRegenerateSecondaryKey.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/conftest.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/conftest.py new file mode 100644 index 000000000000..aee49742dee2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + apimanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + apimanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + apimanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + apimanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=apimanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=apimanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=apimanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=apimanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management.py new file mode 100644 index 000000000000..d215a7a10f53 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagement(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_perform_connectivity_check_async(self, resource_group): + response = self.client.begin_perform_connectivity_check_async( + resource_group_name=resource_group.name, + service_name="str", + connectivity_check_request_params={ + "destination": {"address": "str", "port": 0}, + "source": {"region": "str", "instance": 0}, + "preferredIPVersion": "str", + "protocol": "str", + "protocolConfiguration": { + "HTTPConfiguration": { + "headers": [{"name": "str", "value": "str"}], + "method": "str", + "validStatusCodes": [0], + } + }, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_all_policies_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_all_policies_operations.py new file mode 100644 index 000000000000..fffeaacb01d8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_all_policies_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAllPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.all_policies.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_all_policies_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_all_policies_operations_async.py new file mode 100644 index 000000000000..84e4c6411eb7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_all_policies_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAllPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.all_policies.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations.py new file mode 100644 index 000000000000..cc59922b23f2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations.py @@ -0,0 +1,202 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiDiagnosticOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_diagnostic.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_diagnostic.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_diagnostic.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_diagnostic.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.api_diagnostic.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + if_match="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_diagnostic.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations_async.py new file mode 100644 index 000000000000..a8a10555a464 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations_async.py @@ -0,0 +1,203 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiDiagnosticOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_diagnostic.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_diagnostic.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_diagnostic.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_diagnostic.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.api_diagnostic.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + if_match="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_diagnostic.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + diagnostic_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations.py new file mode 100644 index 000000000000..3d65d9876434 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiExportOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_export.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + format="str", + export="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations_async.py new file mode 100644 index 000000000000..7206f79f4fca --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations_async.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiExportOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_export.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + format="str", + export="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations.py new file mode 100644 index 000000000000..2ef59fe3d20c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiGatewayConfigConnectionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_gateway(self, resource_group): + response = self.client.api_gateway_config_connection.list_by_gateway( + resource_group_name=resource_group.name, + gateway_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_gateway_config_connection.get( + resource_group_name=resource_group.name, + gateway_name="str", + config_connection_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.api_gateway_config_connection.begin_create_or_update( + resource_group_name=resource_group.name, + gateway_name="str", + config_connection_name="str", + parameters={ + "defaultHostname": "str", + "etag": "str", + "hostnames": ["str"], + "id": "str", + "name": "str", + "provisioningState": "str", + "sourceId": "str", + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.api_gateway_config_connection.begin_delete( + resource_group_name=resource_group.name, + gateway_name="str", + config_connection_name="str", + if_match="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations_async.py new file mode 100644 index 000000000000..70d15e2f2673 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiGatewayConfigConnectionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_gateway(self, resource_group): + response = self.client.api_gateway_config_connection.list_by_gateway( + resource_group_name=resource_group.name, + gateway_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_gateway_config_connection.get( + resource_group_name=resource_group.name, + gateway_name="str", + config_connection_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.api_gateway_config_connection.begin_create_or_update( + resource_group_name=resource_group.name, + gateway_name="str", + config_connection_name="str", + parameters={ + "defaultHostname": "str", + "etag": "str", + "hostnames": ["str"], + "id": "str", + "name": "str", + "provisioningState": "str", + "sourceId": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.api_gateway_config_connection.begin_delete( + resource_group_name=resource_group.name, + gateway_name="str", + config_connection_name="str", + if_match="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_operations.py new file mode 100644 index 000000000000..b36c0009b8c7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_operations.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiGatewayOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.api_gateway.begin_create_or_update( + resource_group_name=resource_group.name, + gateway_name="str", + parameters={ + "location": "str", + "sku": {"name": "str", "capacity": 0}, + "backend": {"subnet": {"id": "str"}}, + "configurationApi": {"hostname": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "etag": "str", + "frontend": {"defaultHostname": "str"}, + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "targetProvisioningState": "str", + "type": "str", + "virtualNetworkType": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.api_gateway.begin_update( + resource_group_name=resource_group.name, + gateway_name="str", + parameters={ + "backend": {"subnet": {"id": "str"}}, + "configurationApi": {"hostname": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "etag": "str", + "frontend": {"defaultHostname": "str"}, + "id": "str", + "name": "str", + "provisioningState": "str", + "sku": {"capacity": 0, "name": "str"}, + "tags": {"str": "str"}, + "targetProvisioningState": "str", + "type": "str", + "virtualNetworkType": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_gateway.get( + resource_group_name=resource_group.name, + gateway_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.api_gateway.begin_delete( + resource_group_name=resource_group.name, + gateway_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.api_gateway.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.api_gateway.list( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_operations_async.py new file mode 100644 index 000000000000..c9ab3b2a33a1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_operations_async.py @@ -0,0 +1,134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiGatewayOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.api_gateway.begin_create_or_update( + resource_group_name=resource_group.name, + gateway_name="str", + parameters={ + "location": "str", + "sku": {"name": "str", "capacity": 0}, + "backend": {"subnet": {"id": "str"}}, + "configurationApi": {"hostname": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "etag": "str", + "frontend": {"defaultHostname": "str"}, + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "targetProvisioningState": "str", + "type": "str", + "virtualNetworkType": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.api_gateway.begin_update( + resource_group_name=resource_group.name, + gateway_name="str", + parameters={ + "backend": {"subnet": {"id": "str"}}, + "configurationApi": {"hostname": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "etag": "str", + "frontend": {"defaultHostname": "str"}, + "id": "str", + "name": "str", + "provisioningState": "str", + "sku": {"capacity": 0, "name": "str"}, + "tags": {"str": "str"}, + "targetProvisioningState": "str", + "type": "str", + "virtualNetworkType": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_gateway.get( + resource_group_name=resource_group.name, + gateway_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.api_gateway.begin_delete( + resource_group_name=resource_group.name, + gateway_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.api_gateway.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.api_gateway.list( + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations.py new file mode 100644 index 000000000000..0f36c4d2e6c8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiIssueAttachmentOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_issue_attachment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_issue_attachment.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + attachment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_issue_attachment.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + attachment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_issue_attachment.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + attachment_id="str", + parameters={ + "content": "str", + "contentFormat": "str", + "id": "str", + "name": "str", + "title": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_issue_attachment.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + attachment_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations_async.py new file mode 100644 index 000000000000..38e28b88ea3e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations_async.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiIssueAttachmentOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_issue_attachment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_issue_attachment.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + attachment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_issue_attachment.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + attachment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_issue_attachment.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + attachment_id="str", + parameters={ + "content": "str", + "contentFormat": "str", + "id": "str", + "name": "str", + "title": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_issue_attachment.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + attachment_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations.py new file mode 100644 index 000000000000..6d5a17acfff8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiIssueCommentOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_issue_comment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_issue_comment.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + comment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_issue_comment.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + comment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_issue_comment.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + comment_id="str", + parameters={ + "createdDate": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "text": "str", + "type": "str", + "userId": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_issue_comment.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + comment_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations_async.py new file mode 100644 index 000000000000..15adf8dd7924 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations_async.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiIssueCommentOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_issue_comment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_issue_comment.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + comment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_issue_comment.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + comment_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_issue_comment.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + comment_id="str", + parameters={ + "createdDate": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "text": "str", + "type": "str", + "userId": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_issue_comment.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + comment_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations.py new file mode 100644 index 000000000000..1dde724ca3cb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiIssueOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_issue.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_issue.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_issue.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_issue.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + parameters={ + "apiId": "str", + "createdDate": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "name": "str", + "state": "str", + "title": "str", + "type": "str", + "userId": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.api_issue.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + if_match="str", + parameters={ + "apiId": "str", + "createdDate": "2020-02-20 00:00:00", + "description": "str", + "state": "str", + "title": "str", + "userId": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_issue.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations_async.py new file mode 100644 index 000000000000..061d561502cf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations_async.py @@ -0,0 +1,124 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiIssueOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_issue.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_issue.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_issue.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_issue.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + parameters={ + "apiId": "str", + "createdDate": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "name": "str", + "state": "str", + "title": "str", + "type": "str", + "userId": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.api_issue.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + if_match="str", + parameters={ + "apiId": "str", + "createdDate": "2020-02-20 00:00:00", + "description": "str", + "state": "str", + "title": "str", + "userId": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_issue.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + issue_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations.py new file mode 100644 index 000000000000..2c85db4b33df --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementGatewaySkusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_available_skus(self, resource_group): + response = self.client.api_management_gateway_skus.list_available_skus( + resource_group_name=resource_group.name, + gateway_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations_async.py new file mode 100644 index 000000000000..508936d5f178 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementGatewaySkusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_available_skus(self, resource_group): + response = self.client.api_management_gateway_skus.list_available_skus( + resource_group_name=resource_group.name, + gateway_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_operations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_operations_operations.py new file mode 100644 index 000000000000..49edd60a1959 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_operations_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementOperationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.api_management_operations.list( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_operations_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_operations_operations_async.py new file mode 100644 index 000000000000..4ee0cc2c1169 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_operations_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementOperationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.api_management_operations.list( + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_operations.py new file mode 100644 index 000000000000..034c695f0bf9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_operations.py @@ -0,0 +1,398 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementServiceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_restore(self, resource_group): + response = self.client.api_management_service.begin_restore( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "backupName": "str", + "containerName": "str", + "storageAccount": "str", + "accessKey": "str", + "accessType": "AccessKey", + "clientId": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_backup(self, resource_group): + response = self.client.api_management_service.begin_backup( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "backupName": "str", + "containerName": "str", + "storageAccount": "str", + "accessKey": "str", + "accessType": "AccessKey", + "clientId": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.api_management_service.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "location": "str", + "publisherEmail": "str", + "publisherName": "str", + "sku": {"capacity": 0, "name": "str"}, + "additionalLocations": [ + { + "location": "str", + "sku": {"capacity": 0, "name": "str"}, + "disableGateway": False, + "gatewayRegionalUrl": "str", + "natGatewayState": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "privateIPAddresses": ["str"], + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "virtualNetworkConfiguration": { + "subnetResourceId": "str", + "subnetname": "str", + "vnetid": "str", + }, + "zones": ["str"], + } + ], + "apiVersionConstraint": {"minApiVersion": "str"}, + "certificates": [ + { + "storeName": "str", + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "certificatePassword": "str", + "encodedCertificate": "str", + } + ], + "configurationApi": {"legacyApi": "Enabled"}, + "createdAtUtc": "2020-02-20 00:00:00", + "customProperties": {"str": "str"}, + "developerPortalStatus": "Enabled", + "developerPortalUrl": "str", + "disableGateway": False, + "enableClientCertificate": False, + "etag": "str", + "gatewayRegionalUrl": "str", + "gatewayUrl": "str", + "hostnameConfigurations": [ + { + "hostName": "str", + "type": "str", + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "certificatePassword": "str", + "certificateSource": "str", + "certificateStatus": "str", + "defaultSslBinding": False, + "encodedCertificate": "str", + "identityClientId": "str", + "keyVaultId": "str", + "negotiateClientCertificate": False, + } + ], + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "legacyPortalStatus": "Enabled", + "managementApiUrl": "str", + "name": "str", + "natGatewayState": "str", + "notificationSenderEmail": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "portalUrl": "str", + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "privateIPAddresses": ["str"], + "provisioningState": "str", + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "publicNetworkAccess": "str", + "restore": False, + "scmUrl": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "targetProvisioningState": "str", + "type": "str", + "virtualNetworkConfiguration": {"subnetResourceId": "str", "subnetname": "str", "vnetid": "str"}, + "virtualNetworkType": "str", + "zones": ["str"], + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.api_management_service.begin_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "additionalLocations": [ + { + "location": "str", + "sku": {"capacity": 0, "name": "str"}, + "disableGateway": False, + "gatewayRegionalUrl": "str", + "natGatewayState": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "privateIPAddresses": ["str"], + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "virtualNetworkConfiguration": { + "subnetResourceId": "str", + "subnetname": "str", + "vnetid": "str", + }, + "zones": ["str"], + } + ], + "apiVersionConstraint": {"minApiVersion": "str"}, + "certificates": [ + { + "storeName": "str", + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "certificatePassword": "str", + "encodedCertificate": "str", + } + ], + "configurationApi": {"legacyApi": "Enabled"}, + "createdAtUtc": "2020-02-20 00:00:00", + "customProperties": {"str": "str"}, + "developerPortalStatus": "Enabled", + "developerPortalUrl": "str", + "disableGateway": False, + "enableClientCertificate": False, + "etag": "str", + "gatewayRegionalUrl": "str", + "gatewayUrl": "str", + "hostnameConfigurations": [ + { + "hostName": "str", + "type": "str", + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "certificatePassword": "str", + "certificateSource": "str", + "certificateStatus": "str", + "defaultSslBinding": False, + "encodedCertificate": "str", + "identityClientId": "str", + "keyVaultId": "str", + "negotiateClientCertificate": False, + } + ], + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "legacyPortalStatus": "Enabled", + "managementApiUrl": "str", + "name": "str", + "natGatewayState": "str", + "notificationSenderEmail": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "portalUrl": "str", + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "privateIPAddresses": ["str"], + "provisioningState": "str", + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "publicNetworkAccess": "str", + "publisherEmail": "str", + "publisherName": "str", + "restore": False, + "scmUrl": "str", + "sku": {"capacity": 0, "name": "str"}, + "tags": {"str": "str"}, + "targetProvisioningState": "str", + "type": "str", + "virtualNetworkConfiguration": {"subnetResourceId": "str", "subnetname": "str", "vnetid": "str"}, + "virtualNetworkType": "str", + "zones": ["str"], + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_management_service.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.api_management_service.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_migrate_to_stv2(self, resource_group): + response = self.client.api_management_service.begin_migrate_to_stv2( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.api_management_service.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.api_management_service.list( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_sso_token(self, resource_group): + response = self.client.api_management_service.get_sso_token( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.api_management_service.check_name_availability( + parameters={"name": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_domain_ownership_identifier(self, resource_group): + response = self.client.api_management_service.get_domain_ownership_identifier( + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_apply_network_configuration_updates(self, resource_group): + response = self.client.api_management_service.begin_apply_network_configuration_updates( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_operations_async.py new file mode 100644 index 000000000000..5166b661309a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_operations_async.py @@ -0,0 +1,413 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementServiceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_restore(self, resource_group): + response = await ( + await self.client.api_management_service.begin_restore( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "backupName": "str", + "containerName": "str", + "storageAccount": "str", + "accessKey": "str", + "accessType": "AccessKey", + "clientId": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_backup(self, resource_group): + response = await ( + await self.client.api_management_service.begin_backup( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "backupName": "str", + "containerName": "str", + "storageAccount": "str", + "accessKey": "str", + "accessType": "AccessKey", + "clientId": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.api_management_service.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "location": "str", + "publisherEmail": "str", + "publisherName": "str", + "sku": {"capacity": 0, "name": "str"}, + "additionalLocations": [ + { + "location": "str", + "sku": {"capacity": 0, "name": "str"}, + "disableGateway": False, + "gatewayRegionalUrl": "str", + "natGatewayState": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "privateIPAddresses": ["str"], + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "virtualNetworkConfiguration": { + "subnetResourceId": "str", + "subnetname": "str", + "vnetid": "str", + }, + "zones": ["str"], + } + ], + "apiVersionConstraint": {"minApiVersion": "str"}, + "certificates": [ + { + "storeName": "str", + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "certificatePassword": "str", + "encodedCertificate": "str", + } + ], + "configurationApi": {"legacyApi": "Enabled"}, + "createdAtUtc": "2020-02-20 00:00:00", + "customProperties": {"str": "str"}, + "developerPortalStatus": "Enabled", + "developerPortalUrl": "str", + "disableGateway": False, + "enableClientCertificate": False, + "etag": "str", + "gatewayRegionalUrl": "str", + "gatewayUrl": "str", + "hostnameConfigurations": [ + { + "hostName": "str", + "type": "str", + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "certificatePassword": "str", + "certificateSource": "str", + "certificateStatus": "str", + "defaultSslBinding": False, + "encodedCertificate": "str", + "identityClientId": "str", + "keyVaultId": "str", + "negotiateClientCertificate": False, + } + ], + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "legacyPortalStatus": "Enabled", + "managementApiUrl": "str", + "name": "str", + "natGatewayState": "str", + "notificationSenderEmail": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "portalUrl": "str", + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "privateIPAddresses": ["str"], + "provisioningState": "str", + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "publicNetworkAccess": "str", + "restore": False, + "scmUrl": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "targetProvisioningState": "str", + "type": "str", + "virtualNetworkConfiguration": {"subnetResourceId": "str", "subnetname": "str", "vnetid": "str"}, + "virtualNetworkType": "str", + "zones": ["str"], + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.api_management_service.begin_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "additionalLocations": [ + { + "location": "str", + "sku": {"capacity": 0, "name": "str"}, + "disableGateway": False, + "gatewayRegionalUrl": "str", + "natGatewayState": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "privateIPAddresses": ["str"], + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "virtualNetworkConfiguration": { + "subnetResourceId": "str", + "subnetname": "str", + "vnetid": "str", + }, + "zones": ["str"], + } + ], + "apiVersionConstraint": {"minApiVersion": "str"}, + "certificates": [ + { + "storeName": "str", + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "certificatePassword": "str", + "encodedCertificate": "str", + } + ], + "configurationApi": {"legacyApi": "Enabled"}, + "createdAtUtc": "2020-02-20 00:00:00", + "customProperties": {"str": "str"}, + "developerPortalStatus": "Enabled", + "developerPortalUrl": "str", + "disableGateway": False, + "enableClientCertificate": False, + "etag": "str", + "gatewayRegionalUrl": "str", + "gatewayUrl": "str", + "hostnameConfigurations": [ + { + "hostName": "str", + "type": "str", + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "certificatePassword": "str", + "certificateSource": "str", + "certificateStatus": "str", + "defaultSslBinding": False, + "encodedCertificate": "str", + "identityClientId": "str", + "keyVaultId": "str", + "negotiateClientCertificate": False, + } + ], + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "legacyPortalStatus": "Enabled", + "managementApiUrl": "str", + "name": "str", + "natGatewayState": "str", + "notificationSenderEmail": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "portalUrl": "str", + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "privateIPAddresses": ["str"], + "provisioningState": "str", + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "publicNetworkAccess": "str", + "publisherEmail": "str", + "publisherName": "str", + "restore": False, + "scmUrl": "str", + "sku": {"capacity": 0, "name": "str"}, + "tags": {"str": "str"}, + "targetProvisioningState": "str", + "type": "str", + "virtualNetworkConfiguration": {"subnetResourceId": "str", "subnetname": "str", "vnetid": "str"}, + "virtualNetworkType": "str", + "zones": ["str"], + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_management_service.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.api_management_service.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_migrate_to_stv2(self, resource_group): + response = await ( + await self.client.api_management_service.begin_migrate_to_stv2( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.api_management_service.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.api_management_service.list( + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_sso_token(self, resource_group): + response = await self.client.api_management_service.get_sso_token( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.api_management_service.check_name_availability( + parameters={"name": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_domain_ownership_identifier(self, resource_group): + response = await self.client.api_management_service.get_domain_ownership_identifier( + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_apply_network_configuration_updates(self, resource_group): + response = await ( + await self.client.api_management_service.begin_apply_network_configuration_updates( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_skus_operations.py new file mode 100644 index 000000000000..85d619a1a0b0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_skus_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementServiceSkusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_available_service_skus(self, resource_group): + response = self.client.api_management_service_skus.list_available_service_skus( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_skus_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_skus_operations_async.py new file mode 100644 index 000000000000..ab1cf34dc124 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_service_skus_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementServiceSkusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_available_service_skus(self, resource_group): + response = self.client.api_management_service_skus.list_available_service_skus( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_skus_operations.py new file mode 100644 index 000000000000..456427649b07 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_skus_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementSkusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.api_management_skus.list( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_skus_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_skus_operations_async.py new file mode 100644 index 000000000000..f6c9760aa184 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_skus_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementSkusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.api_management_skus.list( + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_link_operations.py new file mode 100644 index 000000000000..def15f835c7a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_link_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementWorkspaceLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_management_workspace_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_link_operations_async.py new file mode 100644 index 000000000000..f2bf4b4fdb45 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_link_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementWorkspaceLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_management_workspace_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_links_operations.py new file mode 100644 index 000000000000..97646d86f427 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_links_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementWorkspaceLinksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_management_workspace_links.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_links_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_links_operations_async.py new file mode 100644 index 000000000000..fb81ada0e4d5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_workspace_links_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiManagementWorkspaceLinksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_management_workspace_links.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations.py new file mode 100644 index 000000000000..2ed15f36f2b0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations.py @@ -0,0 +1,379 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiOperationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.api_operation.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_operation.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_operation.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_operation.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "method": "str", + "name": "str", + "policies": "str", + "request": { + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "queryParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + }, + "responses": [ + { + "statusCode": 0, + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + } + ], + "templateParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "type": "str", + "urlTemplate": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.api_operation.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + if_match="str", + parameters={ + "description": "str", + "displayName": "str", + "method": "str", + "policies": "str", + "request": { + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "queryParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + }, + "responses": [ + { + "statusCode": 0, + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + } + ], + "templateParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "urlTemplate": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_operation.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations_async.py new file mode 100644 index 000000000000..ca7f099e7717 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations_async.py @@ -0,0 +1,380 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiOperationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.api_operation.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_operation.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_operation.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_operation.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "method": "str", + "name": "str", + "policies": "str", + "request": { + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "queryParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + }, + "responses": [ + { + "statusCode": 0, + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + } + ], + "templateParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "type": "str", + "urlTemplate": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.api_operation.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + if_match="str", + parameters={ + "description": "str", + "displayName": "str", + "method": "str", + "policies": "str", + "request": { + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "queryParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + }, + "responses": [ + { + "statusCode": 0, + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + } + ], + "templateParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "urlTemplate": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_operation.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations.py new file mode 100644 index 000000000000..8ceefd20ce53 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiOperationPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_operation(self, resource_group): + response = self.client.api_operation_policy.list_by_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_operation_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_operation_policy.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_operation_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_operation_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations_async.py new file mode 100644 index 000000000000..76a6dc87853c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations_async.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiOperationPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_operation(self, resource_group): + response = await self.client.api_operation_policy.list_by_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_operation_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_operation_policy.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_operation_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_operation_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operations.py new file mode 100644 index 000000000000..7488f5d71a96 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operations.py @@ -0,0 +1,177 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.api.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + parameters={ + "apiRevision": "str", + "apiRevisionDescription": "str", + "apiType": "str", + "apiVersion": "str", + "apiVersionDescription": "str", + "apiVersionSet": { + "description": "str", + "id": "str", + "name": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + "apiVersionSetId": "str", + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "str", "scope": "str"}, + "oAuth2AuthenticationSettings": [{"authorizationServerId": "str", "scope": "str"}], + "openid": {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}, + "openidAuthenticationSettings": [{"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}], + }, + "contact": {"email": "str", "name": "str", "url": "str"}, + "description": "str", + "displayName": "str", + "format": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "str"}, + "path": "str", + "protocols": ["str"], + "provisioningState": "str", + "serviceUrl": "str", + "sourceApiId": "str", + "subscriptionKeyParameterNames": {"header": "str", "query": "str"}, + "subscriptionRequired": bool, + "termsOfServiceUrl": "str", + "translateRequiredQueryParameters": "str", + "type": "str", + "value": "str", + "wsdlSelector": {"wsdlEndpointName": "str", "wsdlServiceName": "str"}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.api.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + if_match="str", + parameters={ + "apiRevision": "str", + "apiRevisionDescription": "str", + "apiVersion": "str", + "apiVersionDescription": "str", + "apiVersionSetId": "str", + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "str", "scope": "str"}, + "oAuth2AuthenticationSettings": [{"authorizationServerId": "str", "scope": "str"}], + "openid": {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}, + "openidAuthenticationSettings": [{"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}], + }, + "contact": {"email": "str", "name": "str", "url": "str"}, + "description": "str", + "displayName": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "str"}, + "path": "str", + "protocols": ["str"], + "serviceUrl": "str", + "subscriptionKeyParameterNames": {"header": "str", "query": "str"}, + "subscriptionRequired": bool, + "termsOfServiceUrl": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.api.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + if_match="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_tags(self, resource_group): + response = self.client.api.list_by_tags( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operations_async.py new file mode 100644 index 000000000000..2d9f47f5d7c6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operations_async.py @@ -0,0 +1,184 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.api.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + parameters={ + "apiRevision": "str", + "apiRevisionDescription": "str", + "apiType": "str", + "apiVersion": "str", + "apiVersionDescription": "str", + "apiVersionSet": { + "description": "str", + "id": "str", + "name": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + "apiVersionSetId": "str", + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "str", "scope": "str"}, + "oAuth2AuthenticationSettings": [{"authorizationServerId": "str", "scope": "str"}], + "openid": {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}, + "openidAuthenticationSettings": [ + {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"} + ], + }, + "contact": {"email": "str", "name": "str", "url": "str"}, + "description": "str", + "displayName": "str", + "format": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "str"}, + "path": "str", + "protocols": ["str"], + "provisioningState": "str", + "serviceUrl": "str", + "sourceApiId": "str", + "subscriptionKeyParameterNames": {"header": "str", "query": "str"}, + "subscriptionRequired": bool, + "termsOfServiceUrl": "str", + "translateRequiredQueryParameters": "str", + "type": "str", + "value": "str", + "wsdlSelector": {"wsdlEndpointName": "str", "wsdlServiceName": "str"}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.api.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + if_match="str", + parameters={ + "apiRevision": "str", + "apiRevisionDescription": "str", + "apiVersion": "str", + "apiVersionDescription": "str", + "apiVersionSetId": "str", + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "str", "scope": "str"}, + "oAuth2AuthenticationSettings": [{"authorizationServerId": "str", "scope": "str"}], + "openid": {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}, + "openidAuthenticationSettings": [{"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}], + }, + "contact": {"email": "str", "name": "str", "url": "str"}, + "description": "str", + "displayName": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "str"}, + "path": "str", + "protocols": ["str"], + "serviceUrl": "str", + "subscriptionKeyParameterNames": {"header": "str", "query": "str"}, + "subscriptionRequired": bool, + "termsOfServiceUrl": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.api.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + if_match="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_tags(self, resource_group): + response = self.client.api.list_by_tags( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_policy_operations.py new file mode 100644 index 000000000000..604a0f4a92ec --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_policy_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.api_policy.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_policy.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_policy_operations_async.py new file mode 100644 index 000000000000..8d0ab935b343 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_policy_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = await self.client.api_policy.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_policy.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_product_operations.py new file mode 100644 index 000000000000..1cb77ac2452e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_product_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiProductOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_apis(self, resource_group): + response = self.client.api_product.list_by_apis( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_product_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_product_operations_async.py new file mode 100644 index 000000000000..a5458614ebb4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_product_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiProductOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_apis(self, resource_group): + response = self.client.api_product.list_by_apis( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations.py new file mode 100644 index 000000000000..6c54ace534ac --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiReleaseOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_release.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_release.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_release.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_release.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + parameters={ + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "notes": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.api_release.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + if_match="str", + parameters={ + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "notes": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_release.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations_async.py new file mode 100644 index 000000000000..b2639d303c4d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations_async.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiReleaseOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_release.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_release.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_release.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_release.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + parameters={ + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "notes": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.api_release.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + if_match="str", + parameters={ + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "notes": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_release.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + release_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations.py new file mode 100644 index 000000000000..ac2002f31d23 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiRevisionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_revision.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations_async.py new file mode 100644 index 000000000000..00f358dbfb3f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiRevisionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_revision.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations.py new file mode 100644 index 000000000000..d31c9f5500a7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiSchemaOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.api_schema.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_schema.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_schema.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.api_schema.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + schema_id="str", + parameters={ + "components": {}, + "contentType": "str", + "definitions": {}, + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_schema.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + schema_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations_async.py new file mode 100644 index 000000000000..997b99237990 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations_async.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiSchemaOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.api_schema.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_schema.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_schema.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.api_schema.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + schema_id="str", + parameters={ + "components": {}, + "contentType": "str", + "definitions": {}, + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_schema.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + schema_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations.py new file mode 100644 index 000000000000..5bd203c8a6ff --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiTagDescriptionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_tag_description.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_tag_description.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_description_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_tag_description.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_description_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_tag_description.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_description_id="str", + parameters={"description": "str", "externalDocsDescription": "str", "externalDocsUrl": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_tag_description.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_description_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations_async.py new file mode 100644 index 000000000000..8919ba043744 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiTagDescriptionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_tag_description.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_tag_description.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_description_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_tag_description.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_description_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_tag_description.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_description_id="str", + parameters={"description": "str", "externalDocsDescription": "str", "externalDocsUrl": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_tag_description.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_description_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations.py new file mode 100644 index 000000000000..5518d3988a40 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiVersionSetOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.api_version_set.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_version_set.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_version_set.get( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_version_set.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "type": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.api_version_set.update( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + if_match="str", + parameters={ + "description": "str", + "displayName": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_version_set.delete( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations_async.py new file mode 100644 index 000000000000..021040a263a8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations_async.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiVersionSetOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.api_version_set.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_version_set.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_version_set.get( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_version_set.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "type": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.api_version_set.update( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + if_match="str", + parameters={ + "description": "str", + "displayName": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_version_set.delete( + resource_group_name=resource_group.name, + service_name="str", + version_set_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations.py new file mode 100644 index 000000000000..79c9d0bf0cbc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiWikiOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.api_wiki.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.api_wiki.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.api_wiki.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + parameters={"documents": [{"documentationId": "str"}], "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.api_wiki.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + if_match="str", + parameters={"documents": [{"documentationId": "str"}]}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.api_wiki.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations_async.py new file mode 100644 index 000000000000..7cf2549dea2e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiWikiOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.api_wiki.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.api_wiki.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.api_wiki.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + parameters={"documents": [{"documentationId": "str"}], "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.api_wiki.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + if_match="str", + parameters={"documents": [{"documentationId": "str"}]}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.api_wiki.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wikis_operations.py new file mode 100644 index 000000000000..b53ab76d0e94 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wikis_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiWikisOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.api_wikis.list( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wikis_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wikis_operations_async.py new file mode 100644 index 000000000000..4409781eaeb5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wikis_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementApiWikisOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.api_wikis.list( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_async.py new file mode 100644 index 000000000000..f4d8f7a19d91 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_perform_connectivity_check_async(self, resource_group): + response = await ( + await self.client.begin_perform_connectivity_check_async( + resource_group_name=resource_group.name, + service_name="str", + connectivity_check_request_params={ + "destination": {"address": "str", "port": 0}, + "source": {"region": "str", "instance": 0}, + "preferredIPVersion": "str", + "protocol": "str", + "protocolConfiguration": { + "HTTPConfiguration": { + "headers": [{"name": "str", "value": "str"}], + "method": "str", + "validStatusCodes": [0], + } + }, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations.py new file mode 100644 index 000000000000..b3303eaee50e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationAccessPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_authorization(self, resource_group): + response = self.client.authorization_access_policy.list_by_authorization( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.authorization_access_policy.get( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + authorization_access_policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.authorization_access_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + authorization_access_policy_id="str", + parameters={ + "appIds": ["str"], + "id": "str", + "name": "str", + "objectId": "str", + "tenantId": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.authorization_access_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + authorization_access_policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations_async.py new file mode 100644 index 000000000000..796dee84ee8d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations_async.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationAccessPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_authorization(self, resource_group): + response = self.client.authorization_access_policy.list_by_authorization( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.authorization_access_policy.get( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + authorization_access_policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.authorization_access_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + authorization_access_policy_id="str", + parameters={ + "appIds": ["str"], + "id": "str", + "name": "str", + "objectId": "str", + "tenantId": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.authorization_access_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + authorization_access_policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations.py new file mode 100644 index 000000000000..19c0d466236a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationLoginLinksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_post(self, resource_group): + response = self.client.authorization_login_links.post( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + parameters={"postLoginRedirectUrl": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations_async.py new file mode 100644 index 000000000000..673357bfeabd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations_async.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationLoginLinksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_post(self, resource_group): + response = await self.client.authorization_login_links.post( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + parameters={"postLoginRedirectUrl": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_operations.py new file mode 100644 index 000000000000..ae61f4c5bed9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_authorization_provider(self, resource_group): + response = self.client.authorization.list_by_authorization_provider( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.authorization.get( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.authorization.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + parameters={ + "authorizationType": "str", + "error": {"code": "str", "message": "str"}, + "id": "str", + "name": "str", + "oauth2grantType": "str", + "parameters": {"str": "str"}, + "status": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.authorization.delete( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_confirm_consent_code(self, resource_group): + response = self.client.authorization.confirm_consent_code( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + parameters={"consentCode": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_operations_async.py new file mode 100644 index 000000000000..c4f2c64a3962 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_authorization_provider(self, resource_group): + response = self.client.authorization.list_by_authorization_provider( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.authorization.get( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.authorization.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + parameters={ + "authorizationType": "str", + "error": {"code": "str", "message": "str"}, + "id": "str", + "name": "str", + "oauth2grantType": "str", + "parameters": {"str": "str"}, + "status": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.authorization.delete( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_confirm_consent_code(self, resource_group): + response = await self.client.authorization.confirm_consent_code( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + authorization_id="str", + parameters={"consentCode": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_provider_operations.py new file mode 100644 index 000000000000..7830a3eb95af --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_provider_operations.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationProviderOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.authorization_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.authorization_provider.get( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.authorization_provider.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + parameters={ + "displayName": "str", + "id": "str", + "identityProvider": "str", + "name": "str", + "oauth2": { + "grantTypes": {"authorizationCode": {"str": "str"}, "clientCredentials": {"str": "str"}}, + "redirectUrl": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.authorization_provider.delete( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_provider_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_provider_operations_async.py new file mode 100644 index 000000000000..351b6392c7f5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_provider_operations_async.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationProviderOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.authorization_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.authorization_provider.get( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.authorization_provider.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + parameters={ + "displayName": "str", + "id": "str", + "identityProvider": "str", + "name": "str", + "oauth2": { + "grantTypes": {"authorizationCode": {"str": "str"}, "clientCredentials": {"str": "str"}}, + "redirectUrl": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.authorization_provider.delete( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_server_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_server_operations.py new file mode 100644 index 000000000000..495b2ef22c60 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_server_operations.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationServerOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.authorization_server.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.authorization_server.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.authorization_server.get( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.authorization_server.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + parameters={ + "authorizationEndpoint": "str", + "authorizationMethods": ["str"], + "bearerTokenSendingMethods": ["str"], + "clientAuthenticationMethod": ["str"], + "clientId": "str", + "clientRegistrationEndpoint": "str", + "clientSecret": "str", + "defaultScope": "str", + "description": "str", + "displayName": "str", + "grantTypes": ["str"], + "id": "str", + "name": "str", + "resourceOwnerPassword": "str", + "resourceOwnerUsername": "str", + "supportState": bool, + "tokenBodyParameters": [{"name": "str", "value": "str"}], + "tokenEndpoint": "str", + "type": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.authorization_server.update( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + if_match="str", + parameters={ + "authorizationEndpoint": "str", + "authorizationMethods": ["str"], + "bearerTokenSendingMethods": ["str"], + "clientAuthenticationMethod": ["str"], + "clientId": "str", + "clientRegistrationEndpoint": "str", + "clientSecret": "str", + "defaultScope": "str", + "description": "str", + "displayName": "str", + "grantTypes": ["str"], + "id": "str", + "name": "str", + "resourceOwnerPassword": "str", + "resourceOwnerUsername": "str", + "supportState": bool, + "tokenBodyParameters": [{"name": "str", "value": "str"}], + "tokenEndpoint": "str", + "type": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.authorization_server.delete( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_secrets(self, resource_group): + response = self.client.authorization_server.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_server_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_server_operations_async.py new file mode 100644 index 000000000000..3f85b9407170 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_server_operations_async.py @@ -0,0 +1,158 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementAuthorizationServerOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.authorization_server.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.authorization_server.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.authorization_server.get( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.authorization_server.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + parameters={ + "authorizationEndpoint": "str", + "authorizationMethods": ["str"], + "bearerTokenSendingMethods": ["str"], + "clientAuthenticationMethod": ["str"], + "clientId": "str", + "clientRegistrationEndpoint": "str", + "clientSecret": "str", + "defaultScope": "str", + "description": "str", + "displayName": "str", + "grantTypes": ["str"], + "id": "str", + "name": "str", + "resourceOwnerPassword": "str", + "resourceOwnerUsername": "str", + "supportState": bool, + "tokenBodyParameters": [{"name": "str", "value": "str"}], + "tokenEndpoint": "str", + "type": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.authorization_server.update( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + if_match="str", + parameters={ + "authorizationEndpoint": "str", + "authorizationMethods": ["str"], + "bearerTokenSendingMethods": ["str"], + "clientAuthenticationMethod": ["str"], + "clientId": "str", + "clientRegistrationEndpoint": "str", + "clientSecret": "str", + "defaultScope": "str", + "description": "str", + "displayName": "str", + "grantTypes": ["str"], + "id": "str", + "name": "str", + "resourceOwnerPassword": "str", + "resourceOwnerUsername": "str", + "supportState": bool, + "tokenBodyParameters": [{"name": "str", "value": "str"}], + "tokenEndpoint": "str", + "type": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.authorization_server.delete( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_secrets(self, resource_group): + response = await self.client.authorization_server.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + authsid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_backend_operations.py new file mode 100644 index 000000000000..392c247d96cc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_backend_operations.py @@ -0,0 +1,201 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementBackendOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.backend.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.backend.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.backend.get( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.backend.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + parameters={ + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "name": "str", + "tripDuration": "1 day, 0:00:00", + } + ] + }, + "credentials": { + "authorization": {"parameter": "str", "scheme": "str"}, + "certificate": ["str"], + "certificateIds": ["str"], + "header": {"str": ["str"]}, + "query": {"str": ["str"]}, + }, + "description": "str", + "id": "str", + "name": "str", + "pool": {"services": [{"id": "str", "priority": 0, "weight": 0}]}, + "properties": { + "serviceFabricCluster": { + "managementEndpoints": ["str"], + "clientCertificateId": "str", + "clientCertificatethumbprint": "str", + "maxPartitionResolutionRetries": 0, + "serverCertificateThumbprints": ["str"], + "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], + } + }, + "protocol": "str", + "proxy": {"url": "str", "password": "str", "username": "str"}, + "resourceId": "str", + "title": "str", + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "type": "str", + "url": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.backend.update( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + if_match="str", + parameters={ + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "name": "str", + "tripDuration": "1 day, 0:00:00", + } + ] + }, + "credentials": { + "authorization": {"parameter": "str", "scheme": "str"}, + "certificate": ["str"], + "certificateIds": ["str"], + "header": {"str": ["str"]}, + "query": {"str": ["str"]}, + }, + "description": "str", + "pool": {"services": [{"id": "str", "priority": 0, "weight": 0}]}, + "properties": { + "serviceFabricCluster": { + "managementEndpoints": ["str"], + "clientCertificateId": "str", + "clientCertificatethumbprint": "str", + "maxPartitionResolutionRetries": 0, + "serverCertificateThumbprints": ["str"], + "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], + } + }, + "protocol": "str", + "proxy": {"url": "str", "password": "str", "username": "str"}, + "resourceId": "str", + "title": "str", + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "type": "str", + "url": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.backend.delete( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_reconnect(self, resource_group): + response = self.client.backend.reconnect( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_backend_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_backend_operations_async.py new file mode 100644 index 000000000000..dd3179a2bb17 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_backend_operations_async.py @@ -0,0 +1,202 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementBackendOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.backend.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.backend.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.backend.get( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.backend.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + parameters={ + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "name": "str", + "tripDuration": "1 day, 0:00:00", + } + ] + }, + "credentials": { + "authorization": {"parameter": "str", "scheme": "str"}, + "certificate": ["str"], + "certificateIds": ["str"], + "header": {"str": ["str"]}, + "query": {"str": ["str"]}, + }, + "description": "str", + "id": "str", + "name": "str", + "pool": {"services": [{"id": "str", "priority": 0, "weight": 0}]}, + "properties": { + "serviceFabricCluster": { + "managementEndpoints": ["str"], + "clientCertificateId": "str", + "clientCertificatethumbprint": "str", + "maxPartitionResolutionRetries": 0, + "serverCertificateThumbprints": ["str"], + "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], + } + }, + "protocol": "str", + "proxy": {"url": "str", "password": "str", "username": "str"}, + "resourceId": "str", + "title": "str", + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "type": "str", + "url": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.backend.update( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + if_match="str", + parameters={ + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "name": "str", + "tripDuration": "1 day, 0:00:00", + } + ] + }, + "credentials": { + "authorization": {"parameter": "str", "scheme": "str"}, + "certificate": ["str"], + "certificateIds": ["str"], + "header": {"str": ["str"]}, + "query": {"str": ["str"]}, + }, + "description": "str", + "pool": {"services": [{"id": "str", "priority": 0, "weight": 0}]}, + "properties": { + "serviceFabricCluster": { + "managementEndpoints": ["str"], + "clientCertificateId": "str", + "clientCertificatethumbprint": "str", + "maxPartitionResolutionRetries": 0, + "serverCertificateThumbprints": ["str"], + "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], + } + }, + "protocol": "str", + "proxy": {"url": "str", "password": "str", "username": "str"}, + "resourceId": "str", + "title": "str", + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "type": "str", + "url": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.backend.delete( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_reconnect(self, resource_group): + response = await self.client.backend.reconnect( + resource_group_name=resource_group.name, + service_name="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations.py new file mode 100644 index 000000000000..88a276c8492e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementCacheOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.cache.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.cache.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.cache.get( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.cache.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + parameters={ + "connectionString": "str", + "description": "str", + "id": "str", + "name": "str", + "resourceId": "str", + "type": "str", + "useFromLocation": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.cache.update( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + if_match="str", + parameters={"connectionString": "str", "description": "str", "resourceId": "str", "useFromLocation": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.cache.delete( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations_async.py new file mode 100644 index 000000000000..4bb0cd96b153 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations_async.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementCacheOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.cache.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.cache.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.cache.get( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.cache.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + parameters={ + "connectionString": "str", + "description": "str", + "id": "str", + "name": "str", + "resourceId": "str", + "type": "str", + "useFromLocation": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.cache.update( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + if_match="str", + parameters={"connectionString": "str", "description": "str", "resourceId": "str", "useFromLocation": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.cache.delete( + resource_group_name=resource_group.name, + service_name="str", + cache_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations.py new file mode 100644 index 000000000000..fd0fd6a92cf6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementCertificateOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.certificate.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.certificate.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.certificate.get( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.certificate.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + parameters={ + "data": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "password": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.certificate.delete( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_refresh_secret(self, resource_group): + response = self.client.certificate.refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations_async.py new file mode 100644 index 000000000000..a97404fd8f39 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations_async.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementCertificateOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.certificate.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.certificate.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.certificate.get( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.certificate.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + parameters={ + "data": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "password": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.certificate.delete( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_refresh_secret(self, resource_group): + response = await self.client.certificate.refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations.py new file mode 100644 index 000000000000..c1cc7d38cf60 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementContentItemOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.content_item.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.content_item.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + content_item_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.content_item.get( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + content_item_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.content_item.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + content_item_id="str", + parameters={"id": "str", "name": "str", "properties": {"str": {}}, "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.content_item.delete( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + content_item_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations_async.py new file mode 100644 index 000000000000..10fb21168765 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementContentItemOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.content_item.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.content_item.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + content_item_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.content_item.get( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + content_item_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.content_item.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + content_item_id="str", + parameters={"id": "str", "name": "str", "properties": {"str": {}}, "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.content_item.delete( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + content_item_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations.py new file mode 100644 index 000000000000..181efa7decc3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementContentTypeOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.content_type.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.content_type.get( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.content_type.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + parameters={ + "description": "str", + "id": "str", + "name": "str", + "schema": {}, + "type": "str", + "version": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.content_type.delete( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations_async.py new file mode 100644 index 000000000000..d870cb5e19cd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations_async.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementContentTypeOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.content_type.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.content_type.get( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.content_type.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + parameters={ + "description": "str", + "id": "str", + "name": "str", + "schema": {}, + "type": "str", + "version": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.content_type.delete( + resource_group_name=resource_group.name, + service_name="str", + content_type_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations.py new file mode 100644 index 000000000000..8d5a5e7d2776 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementDelegationSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.delegation_settings.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.delegation_settings.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.delegation_settings.update( + resource_group_name=resource_group.name, + service_name="str", + if_match="str", + parameters={ + "id": "str", + "name": "str", + "subscriptions": {"enabled": bool}, + "type": "str", + "url": "str", + "userRegistration": {"enabled": bool}, + "validationKey": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.delegation_settings.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "id": "str", + "name": "str", + "subscriptions": {"enabled": bool}, + "type": "str", + "url": "str", + "userRegistration": {"enabled": bool}, + "validationKey": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_secrets(self, resource_group): + response = self.client.delegation_settings.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations_async.py new file mode 100644 index 000000000000..02ccb62ee09f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations_async.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementDelegationSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.delegation_settings.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.delegation_settings.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.delegation_settings.update( + resource_group_name=resource_group.name, + service_name="str", + if_match="str", + parameters={ + "id": "str", + "name": "str", + "subscriptions": {"enabled": bool}, + "type": "str", + "url": "str", + "userRegistration": {"enabled": bool}, + "validationKey": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.delegation_settings.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "id": "str", + "name": "str", + "subscriptions": {"enabled": bool}, + "type": "str", + "url": "str", + "userRegistration": {"enabled": bool}, + "validationKey": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_secrets(self, resource_group): + response = await self.client.delegation_settings.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations.py new file mode 100644 index 000000000000..29cc03dc7758 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementDeletedServicesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.deleted_services.list_by_subscription( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_name(self, resource_group): + response = self.client.deleted_services.get_by_name( + service_name="str", + location="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_purge(self, resource_group): + response = self.client.deleted_services.begin_purge( + service_name="str", + location="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations_async.py new file mode 100644 index 000000000000..fbbb22ed24ef --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations_async.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementDeletedServicesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.deleted_services.list_by_subscription( + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_name(self, resource_group): + response = await self.client.deleted_services.get_by_name( + service_name="str", + location="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_purge(self, resource_group): + response = await ( + await self.client.deleted_services.begin_purge( + service_name="str", + location="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations.py new file mode 100644 index 000000000000..0f6e82b7a1c8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations.py @@ -0,0 +1,196 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementDiagnosticOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.diagnostic.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.diagnostic.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.diagnostic.get( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.diagnostic.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.diagnostic.update( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + if_match="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.diagnostic.delete( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations_async.py new file mode 100644 index 000000000000..52bb85fc84f9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations_async.py @@ -0,0 +1,197 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementDiagnosticOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.diagnostic.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.diagnostic.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.diagnostic.get( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.diagnostic.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.diagnostic.update( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + if_match="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.diagnostic.delete( + resource_group_name=resource_group.name, + service_name="str", + diagnostic_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations.py new file mode 100644 index 000000000000..449a7363fb15 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementDocumentationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.documentation.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.documentation.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.documentation.get( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.documentation.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + parameters={"content": "str", "id": "str", "name": "str", "title": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.documentation.update( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + if_match="str", + parameters={"content": "str", "title": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.documentation.delete( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations_async.py new file mode 100644 index 000000000000..cb3fffdb2d44 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementDocumentationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.documentation.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.documentation.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.documentation.get( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.documentation.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + parameters={"content": "str", "id": "str", "name": "str", "title": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.documentation.update( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + if_match="str", + parameters={"content": "str", "title": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.documentation.delete( + resource_group_name=resource_group.name, + service_name="str", + documentation_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations.py new file mode 100644 index 000000000000..211b33790e2f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementEmailTemplateOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.email_template.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.email_template.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.email_template.get( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.email_template.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + parameters={ + "body": "str", + "description": "str", + "parameters": [{"description": "str", "name": "str", "title": "str"}], + "subject": "str", + "title": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.email_template.update( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + if_match="str", + parameters={ + "body": "str", + "description": "str", + "parameters": [{"description": "str", "name": "str", "title": "str"}], + "subject": "str", + "title": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.email_template.delete( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations_async.py new file mode 100644 index 000000000000..a05e73d5532d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations_async.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementEmailTemplateOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.email_template.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.email_template.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.email_template.get( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.email_template.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + parameters={ + "body": "str", + "description": "str", + "parameters": [{"description": "str", "name": "str", "title": "str"}], + "subject": "str", + "title": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.email_template.update( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + if_match="str", + parameters={ + "body": "str", + "description": "str", + "parameters": [{"description": "str", "name": "str", "title": "str"}], + "subject": "str", + "title": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.email_template.delete( + resource_group_name=resource_group.name, + service_name="str", + template_name="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations.py new file mode 100644 index 000000000000..c4a416c5dd84 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGatewayApiOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.gateway_api.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.gateway_api.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.gateway_api.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.gateway_api.delete( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations_async.py new file mode 100644 index 000000000000..12334b970d7d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGatewayApiOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.gateway_api.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.gateway_api.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.gateway_api.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.gateway_api.delete( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations.py new file mode 100644 index 000000000000..efa26d783124 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGatewayCertificateAuthorityOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.gateway_certificate_authority.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.gateway_certificate_authority.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.gateway_certificate_authority.get( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.gateway_certificate_authority.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + certificate_id="str", + parameters={"id": "str", "isTrusted": bool, "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.gateway_certificate_authority.delete( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + certificate_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations_async.py new file mode 100644 index 000000000000..40acfbdcc4f3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGatewayCertificateAuthorityOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.gateway_certificate_authority.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.gateway_certificate_authority.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.gateway_certificate_authority.get( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.gateway_certificate_authority.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + certificate_id="str", + parameters={"id": "str", "isTrusted": bool, "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.gateway_certificate_authority.delete( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + certificate_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations.py new file mode 100644 index 000000000000..1f3940e849df --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGatewayHostnameConfigurationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.gateway_hostname_configuration.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.gateway_hostname_configuration.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + hc_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.gateway_hostname_configuration.get( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + hc_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.gateway_hostname_configuration.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + hc_id="str", + parameters={ + "certificateId": "str", + "hostname": "str", + "http2Enabled": bool, + "id": "str", + "name": "str", + "negotiateClientCertificate": bool, + "tls10Enabled": bool, + "tls11Enabled": bool, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.gateway_hostname_configuration.delete( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + hc_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations_async.py new file mode 100644 index 000000000000..c588a132fbf2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGatewayHostnameConfigurationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.gateway_hostname_configuration.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.gateway_hostname_configuration.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + hc_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.gateway_hostname_configuration.get( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + hc_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.gateway_hostname_configuration.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + hc_id="str", + parameters={ + "certificateId": "str", + "hostname": "str", + "http2Enabled": bool, + "id": "str", + "name": "str", + "negotiateClientCertificate": bool, + "tls10Enabled": bool, + "tls11Enabled": bool, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.gateway_hostname_configuration.delete( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + hc_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations.py new file mode 100644 index 000000000000..023345cbee8d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations.py @@ -0,0 +1,194 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGatewayOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.gateway.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.gateway.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.gateway.get( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.gateway.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={ + "description": "str", + "id": "str", + "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + "name": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.gateway.update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + if_match="str", + parameters={ + "description": "str", + "id": "str", + "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + "name": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.gateway.delete( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_keys(self, resource_group): + response = self.client.gateway.list_keys( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_key(self, resource_group): + response = self.client.gateway.regenerate_key( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={"keyType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_generate_token(self, resource_group): + response = self.client.gateway.generate_token( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={"expiry": "2020-02-20 00:00:00", "keyType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_invalidate_debug_credentials(self, resource_group): + response = self.client.gateway.invalidate_debug_credentials( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_debug_credentials(self, resource_group): + response = self.client.gateway.list_debug_credentials( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={"apiId": "str", "purposes": ["str"], "credentialsExpireAfter": "1 day, 0:00:00"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_trace(self, resource_group): + response = self.client.gateway.list_trace( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={"traceId": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations_async.py new file mode 100644 index 000000000000..b1b342422ef8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations_async.py @@ -0,0 +1,195 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGatewayOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.gateway.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.gateway.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.gateway.get( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.gateway.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={ + "description": "str", + "id": "str", + "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + "name": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.gateway.update( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + if_match="str", + parameters={ + "description": "str", + "id": "str", + "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + "name": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.gateway.delete( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_keys(self, resource_group): + response = await self.client.gateway.list_keys( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_key(self, resource_group): + response = await self.client.gateway.regenerate_key( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={"keyType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_generate_token(self, resource_group): + response = await self.client.gateway.generate_token( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={"expiry": "2020-02-20 00:00:00", "keyType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_invalidate_debug_credentials(self, resource_group): + response = await self.client.gateway.invalidate_debug_credentials( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_debug_credentials(self, resource_group): + response = await self.client.gateway.list_debug_credentials( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={"apiId": "str", "purposes": ["str"], "credentialsExpireAfter": "1 day, 0:00:00"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_trace(self, resource_group): + response = await self.client.gateway.list_trace( + resource_group_name=resource_group.name, + service_name="str", + gateway_id="str", + parameters={"traceId": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations.py new file mode 100644 index 000000000000..3e8acd5bb3b2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGlobalSchemaOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.global_schema.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.global_schema.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.global_schema.get( + resource_group_name=resource_group.name, + service_name="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.global_schema.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + schema_id="str", + parameters={ + "description": "str", + "document": {}, + "id": "str", + "name": "str", + "provisioningState": "str", + "schemaType": "str", + "type": "str", + "value": {}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.global_schema.delete( + resource_group_name=resource_group.name, + service_name="str", + schema_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations_async.py new file mode 100644 index 000000000000..cf89a5107cb7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations_async.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGlobalSchemaOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.global_schema.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.global_schema.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.global_schema.get( + resource_group_name=resource_group.name, + service_name="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.global_schema.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + schema_id="str", + parameters={ + "description": "str", + "document": {}, + "id": "str", + "name": "str", + "provisioningState": "str", + "schemaType": "str", + "type": "str", + "value": {}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.global_schema.delete( + resource_group_name=resource_group.name, + service_name="str", + schema_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations.py new file mode 100644 index 000000000000..a19e49124710 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGraphQLApiResolverOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.graph_ql_api_resolver.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.graph_ql_api_resolver.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.graph_ql_api_resolver.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.graph_ql_api_resolver.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "path": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.graph_ql_api_resolver.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + if_match="str", + parameters={"description": "str", "displayName": "str", "path": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.graph_ql_api_resolver.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations_async.py new file mode 100644 index 000000000000..4d37490c750b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations_async.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGraphQLApiResolverOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.graph_ql_api_resolver.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.graph_ql_api_resolver.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.graph_ql_api_resolver.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.graph_ql_api_resolver.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "path": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.graph_ql_api_resolver.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + if_match="str", + parameters={"description": "str", "displayName": "str", "path": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.graph_ql_api_resolver.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_policy_operations.py new file mode 100644 index 000000000000..f8b94cbd98ca --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_policy_operations.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGraphQLApiResolverPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resolver(self, resource_group): + response = self.client.graph_ql_api_resolver_policy.list_by_resolver( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.graph_ql_api_resolver_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.graph_ql_api_resolver_policy.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.graph_ql_api_resolver_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.graph_ql_api_resolver_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_policy_operations_async.py new file mode 100644 index 000000000000..c50d3ea4a710 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_policy_operations_async.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGraphQLApiResolverPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resolver(self, resource_group): + response = self.client.graph_ql_api_resolver_policy.list_by_resolver( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.graph_ql_api_resolver_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.graph_ql_api_resolver_policy.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.graph_ql_api_resolver_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.graph_ql_api_resolver_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + resolver_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations.py new file mode 100644 index 000000000000..9e7ff88f7d54 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGroupOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.group.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.group.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.group.get( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.group.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.group.update( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + if_match="str", + parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.group.delete( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations_async.py new file mode 100644 index 000000000000..5c467ff0e9c1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGroupOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.group.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.group.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.group.get( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.group.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.group.update( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + if_match="str", + parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.group.delete( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations.py new file mode 100644 index 000000000000..ce74f8a5114c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGroupUserOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.group_user.list( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_entity_exists(self, resource_group): + response = self.client.group_user.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.group_user.create( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.group_user.delete( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations_async.py new file mode 100644 index 000000000000..1a3e173c2b82 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementGroupUserOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.group_user.list( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_entity_exists(self, resource_group): + response = await self.client.group_user.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.group_user.create( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.group_user.delete( + resource_group_name=resource_group.name, + service_name="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_identity_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_identity_provider_operations.py new file mode 100644 index 000000000000..334833f073f2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_identity_provider_operations.py @@ -0,0 +1,139 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementIdentityProviderOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.identity_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.identity_provider.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.identity_provider.get( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.identity_provider.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + parameters={ + "allowedTenants": ["str"], + "authority": "str", + "clientId": "str", + "clientLibrary": "str", + "clientSecret": "str", + "id": "str", + "name": "str", + "passwordResetPolicyName": "str", + "profileEditingPolicyName": "str", + "signinPolicyName": "str", + "signinTenant": "str", + "signupPolicyName": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.identity_provider.update( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + if_match="str", + parameters={ + "allowedTenants": ["str"], + "authority": "str", + "clientId": "str", + "clientLibrary": "str", + "clientSecret": "str", + "passwordResetPolicyName": "str", + "profileEditingPolicyName": "str", + "signinPolicyName": "str", + "signinTenant": "str", + "signupPolicyName": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.identity_provider.delete( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_secrets(self, resource_group): + response = self.client.identity_provider.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_identity_provider_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_identity_provider_operations_async.py new file mode 100644 index 000000000000..f8f961643fd0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_identity_provider_operations_async.py @@ -0,0 +1,140 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementIdentityProviderOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.identity_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.identity_provider.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.identity_provider.get( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.identity_provider.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + parameters={ + "allowedTenants": ["str"], + "authority": "str", + "clientId": "str", + "clientLibrary": "str", + "clientSecret": "str", + "id": "str", + "name": "str", + "passwordResetPolicyName": "str", + "profileEditingPolicyName": "str", + "signinPolicyName": "str", + "signinTenant": "str", + "signupPolicyName": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.identity_provider.update( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + if_match="str", + parameters={ + "allowedTenants": ["str"], + "authority": "str", + "clientId": "str", + "clientLibrary": "str", + "clientSecret": "str", + "passwordResetPolicyName": "str", + "profileEditingPolicyName": "str", + "signinPolicyName": "str", + "signinTenant": "str", + "signupPolicyName": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.identity_provider.delete( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_secrets(self, resource_group): + response = await self.client.identity_provider.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + identity_provider_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations.py new file mode 100644 index 000000000000..bcadacae8da2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementIssueOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.issue.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.issue.get( + resource_group_name=resource_group.name, + service_name="str", + issue_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations_async.py new file mode 100644 index 000000000000..b4837138a6ee --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementIssueOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.issue.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.issue.get( + resource_group_name=resource_group.name, + service_name="str", + issue_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations.py new file mode 100644 index 000000000000..ac7c024707dd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementLoggerOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.logger.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.logger.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.logger.get( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.logger.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + parameters={ + "credentials": {"str": "str"}, + "description": "str", + "id": "str", + "isBuffered": bool, + "loggerType": "str", + "name": "str", + "resourceId": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.logger.update( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + if_match="str", + parameters={"credentials": {"str": "str"}, "description": "str", "isBuffered": bool, "loggerType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.logger.delete( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations_async.py new file mode 100644 index 000000000000..d59c3dcc6256 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations_async.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementLoggerOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.logger.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.logger.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.logger.get( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.logger.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + parameters={ + "credentials": {"str": "str"}, + "description": "str", + "id": "str", + "isBuffered": bool, + "loggerType": "str", + "name": "str", + "resourceId": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.logger.update( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + if_match="str", + parameters={"credentials": {"str": "str"}, "description": "str", "isBuffered": bool, "loggerType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.logger.delete( + resource_group_name=resource_group.name, + service_name="str", + logger_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations.py new file mode 100644 index 000000000000..5232f94e6bb8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations.py @@ -0,0 +1,141 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNamedValueOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.named_value.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.named_value.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.named_value.get( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.named_value.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + parameters={ + "displayName": "str", + "id": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "name": "str", + "secret": bool, + "tags": ["str"], + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.named_value.begin_update( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + if_match="str", + parameters={ + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.named_value.delete( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_value(self, resource_group): + response = self.client.named_value.list_value( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_refresh_secret(self, resource_group): + response = self.client.named_value.begin_refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations_async.py new file mode 100644 index 000000000000..23ae6bd04e77 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations_async.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNamedValueOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.named_value.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.named_value.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.named_value.get( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.named_value.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + parameters={ + "displayName": "str", + "id": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "name": "str", + "secret": bool, + "tags": ["str"], + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.named_value.begin_update( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + if_match="str", + parameters={ + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.named_value.delete( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_value(self, resource_group): + response = await self.client.named_value.list_value( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_refresh_secret(self, resource_group): + response = await ( + await self.client.named_value.begin_refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + named_value_id="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_network_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_network_status_operations.py new file mode 100644 index 000000000000..3d9ca6b85c6c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_network_status_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNetworkStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.network_status.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_location(self, resource_group): + response = self.client.network_status.list_by_location( + resource_group_name=resource_group.name, + service_name="str", + location_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_network_status_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_network_status_operations_async.py new file mode 100644 index 000000000000..80ab6d24bade --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_network_status_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNetworkStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = await self.client.network_status.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_location(self, resource_group): + response = await self.client.network_status.list_by_location( + resource_group_name=resource_group.name, + service_name="str", + location_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations.py new file mode 100644 index 000000000000..fbf6dc7d98ef --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNotificationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.notification.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.notification.get( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.notification.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations_async.py new file mode 100644 index 000000000000..ea7f3516da1a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations_async.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNotificationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.notification.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.notification.get( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.notification.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations.py new file mode 100644 index 000000000000..c11da3cbd21a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNotificationRecipientEmailOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_notification(self, resource_group): + response = self.client.notification_recipient_email.list_by_notification( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_entity_exists(self, resource_group): + response = self.client.notification_recipient_email.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.notification_recipient_email.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.notification_recipient_email.delete( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations_async.py new file mode 100644 index 000000000000..12db1ea48e0d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNotificationRecipientEmailOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_notification(self, resource_group): + response = await self.client.notification_recipient_email.list_by_notification( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_entity_exists(self, resource_group): + response = await self.client.notification_recipient_email.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.notification_recipient_email.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.notification_recipient_email.delete( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_user_operations.py new file mode 100644 index 000000000000..40a0cc5a892b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_user_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNotificationRecipientUserOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_notification(self, resource_group): + response = self.client.notification_recipient_user.list_by_notification( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_entity_exists(self, resource_group): + response = self.client.notification_recipient_user.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.notification_recipient_user.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.notification_recipient_user.delete( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_user_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_user_operations_async.py new file mode 100644 index 000000000000..e431ba0d3cf2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_user_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementNotificationRecipientUserOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_notification(self, resource_group): + response = await self.client.notification_recipient_user.list_by_notification( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_entity_exists(self, resource_group): + response = await self.client.notification_recipient_user.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.notification_recipient_user.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.notification_recipient_user.delete( + resource_group_name=resource_group.name, + service_name="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_open_id_connect_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_open_id_connect_provider_operations.py new file mode 100644 index 000000000000..d8c14c7cadec --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_open_id_connect_provider_operations.py @@ -0,0 +1,132 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOpenIdConnectProviderOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.open_id_connect_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.open_id_connect_provider.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.open_id_connect_provider.get( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.open_id_connect_provider.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + parameters={ + "clientId": "str", + "clientSecret": "str", + "description": "str", + "displayName": "str", + "id": "str", + "metadataEndpoint": "str", + "name": "str", + "type": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.open_id_connect_provider.update( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + if_match="str", + parameters={ + "clientId": "str", + "clientSecret": "str", + "description": "str", + "displayName": "str", + "metadataEndpoint": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.open_id_connect_provider.delete( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_secrets(self, resource_group): + response = self.client.open_id_connect_provider.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_open_id_connect_provider_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_open_id_connect_provider_operations_async.py new file mode 100644 index 000000000000..1236e351bc0a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_open_id_connect_provider_operations_async.py @@ -0,0 +1,133 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOpenIdConnectProviderOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.open_id_connect_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.open_id_connect_provider.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.open_id_connect_provider.get( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.open_id_connect_provider.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + parameters={ + "clientId": "str", + "clientSecret": "str", + "description": "str", + "displayName": "str", + "id": "str", + "metadataEndpoint": "str", + "name": "str", + "type": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.open_id_connect_provider.update( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + if_match="str", + parameters={ + "clientId": "str", + "clientSecret": "str", + "description": "str", + "displayName": "str", + "metadataEndpoint": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.open_id_connect_provider.delete( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_secrets(self, resource_group): + response = await self.client.open_id_connect_provider.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + opid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_operations.py new file mode 100644 index 000000000000..bb417d820eb5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOperationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_tags(self, resource_group): + response = self.client.operation.list_by_tags( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_operations_async.py new file mode 100644 index 000000000000..902615a1b23c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOperationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_tags(self, resource_group): + response = self.client.operation.list_by_tags( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_status_operations.py new file mode 100644 index 000000000000..7e8e839a2fe4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_status_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOperationStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operation_status.get( + location="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_status_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_status_operations_async.py new file mode 100644 index 000000000000..9554ed1cd01e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operation_status_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOperationStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operation_status.get( + location="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operations_results_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operations_results_operations.py new file mode 100644 index 000000000000..377efa038596 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operations_results_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOperationsResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operations_results.get( + location="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operations_results_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operations_results_operations_async.py new file mode 100644 index 000000000000..d26a772ede5e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_operations_results_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOperationsResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operations_results.get( + location="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_outbound_network_dependencies_endpoints_operations.py new file mode 100644 index 000000000000..ef03c8d1945e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_outbound_network_dependencies_endpoints_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOutboundNetworkDependenciesEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.outbound_network_dependencies_endpoints.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_outbound_network_dependencies_endpoints_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_outbound_network_dependencies_endpoints_operations_async.py new file mode 100644 index 000000000000..34cedaf43ce0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_outbound_network_dependencies_endpoints_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementOutboundNetworkDependenciesEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = await self.client.outbound_network_dependencies_endpoints.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_description_operations.py new file mode 100644 index 000000000000..ab227e27bd67 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_description_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyDescriptionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.policy_description.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_description_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_description_operations_async.py new file mode 100644 index 000000000000..ad02358f3a25 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_description_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyDescriptionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = await self.client.policy_description.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_fragment_operations.py new file mode 100644 index 000000000000..188256dc59a4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_fragment_operations.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyFragmentOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.policy_fragment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.policy_fragment.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.policy_fragment.get( + resource_group_name=resource_group.name, + service_name="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.policy_fragment.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + id="str", + parameters={ + "description": "str", + "format": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.policy_fragment.delete( + resource_group_name=resource_group.name, + service_name="str", + id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_references(self, resource_group): + response = self.client.policy_fragment.list_references( + resource_group_name=resource_group.name, + service_name="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_fragment_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_fragment_operations_async.py new file mode 100644 index 000000000000..dcc0f6241e5e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_fragment_operations_async.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyFragmentOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.policy_fragment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.policy_fragment.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.policy_fragment.get( + resource_group_name=resource_group.name, + service_name="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.policy_fragment.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + id="str", + parameters={ + "description": "str", + "format": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.policy_fragment.delete( + resource_group_name=resource_group.name, + service_name="str", + id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_references(self, resource_group): + response = await self.client.policy_fragment.list_references( + resource_group_name=resource_group.name, + service_name="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations.py new file mode 100644 index 000000000000..0c0f56ce31ad --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.policy.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.policy.get( + resource_group_name=resource_group.name, + service_name="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.policy.delete( + resource_group_name=resource_group.name, + service_name="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations_async.py new file mode 100644 index 000000000000..dd5a20560327 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.policy.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.policy.get( + resource_group_name=resource_group.name, + service_name="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.policy.delete( + resource_group_name=resource_group.name, + service_name="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations.py new file mode 100644 index 000000000000..05b592268e0e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyRestrictionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.policy_restriction.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.policy_restriction.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.policy_restriction.get( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.policy_restriction.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + parameters={"id": "str", "name": "str", "requireBase": "false", "scope": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.policy_restriction.update( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + if_match="str", + parameters={"requireBase": "false", "scope": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.policy_restriction.delete( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations_async.py new file mode 100644 index 000000000000..7d16980969f6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations_async.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyRestrictionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.policy_restriction.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.policy_restriction.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.policy_restriction.get( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.policy_restriction.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + parameters={"id": "str", "name": "str", "requireBase": "false", "scope": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.policy_restriction.update( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + if_match="str", + parameters={"requireBase": "false", "scope": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.policy_restriction.delete( + resource_group_name=resource_group.name, + service_name="str", + policy_restriction_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations.py new file mode 100644 index 000000000000..bf3bb24c345d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyRestrictionValidationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_by_service(self, resource_group): + response = self.client.policy_restriction_validations.begin_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations_async.py new file mode 100644 index 000000000000..4bde6a3acfb9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPolicyRestrictionValidationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_by_service(self, resource_group): + response = await ( + await self.client.policy_restriction_validations.begin_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations.py new file mode 100644 index 000000000000..50c2ef1e7f71 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPortalConfigOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.portal_config.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.portal_config.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + portal_config_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.portal_config.get( + resource_group_name=resource_group.name, + service_name="str", + portal_config_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.portal_config.update( + resource_group_name=resource_group.name, + service_name="str", + portal_config_id="str", + if_match="str", + parameters={ + "cors": {"allowedOrigins": ["str"]}, + "csp": {"allowedSources": ["str"], "mode": "disabled", "reportUri": ["str"]}, + "delegation": { + "delegateRegistration": False, + "delegateSubscription": False, + "delegationUrl": "str", + "validationKey": "str", + }, + "enableBasicAuth": True, + "id": "str", + "name": "str", + "signin": {"require": False}, + "signup": {"termsOfService": {"requireConsent": False, "text": "str"}}, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.portal_config.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + portal_config_id="str", + if_match="str", + parameters={ + "cors": {"allowedOrigins": ["str"]}, + "csp": {"allowedSources": ["str"], "mode": "disabled", "reportUri": ["str"]}, + "delegation": { + "delegateRegistration": False, + "delegateSubscription": False, + "delegationUrl": "str", + "validationKey": "str", + }, + "enableBasicAuth": True, + "id": "str", + "name": "str", + "signin": {"require": False}, + "signup": {"termsOfService": {"requireConsent": False, "text": "str"}}, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations_async.py new file mode 100644 index 000000000000..db5c4d8916d0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations_async.py @@ -0,0 +1,118 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPortalConfigOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.portal_config.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.portal_config.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + portal_config_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.portal_config.get( + resource_group_name=resource_group.name, + service_name="str", + portal_config_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.portal_config.update( + resource_group_name=resource_group.name, + service_name="str", + portal_config_id="str", + if_match="str", + parameters={ + "cors": {"allowedOrigins": ["str"]}, + "csp": {"allowedSources": ["str"], "mode": "disabled", "reportUri": ["str"]}, + "delegation": { + "delegateRegistration": False, + "delegateSubscription": False, + "delegationUrl": "str", + "validationKey": "str", + }, + "enableBasicAuth": True, + "id": "str", + "name": "str", + "signin": {"require": False}, + "signup": {"termsOfService": {"requireConsent": False, "text": "str"}}, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.portal_config.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + portal_config_id="str", + if_match="str", + parameters={ + "cors": {"allowedOrigins": ["str"]}, + "csp": {"allowedSources": ["str"], "mode": "disabled", "reportUri": ["str"]}, + "delegation": { + "delegateRegistration": False, + "delegateSubscription": False, + "delegationUrl": "str", + "validationKey": "str", + }, + "enableBasicAuth": True, + "id": "str", + "name": "str", + "signin": {"require": False}, + "signup": {"termsOfService": {"requireConsent": False, "text": "str"}}, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations.py new file mode 100644 index 000000000000..a55f2bd94c55 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPortalRevisionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.portal_revision.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.portal_revision.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + portal_revision_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.portal_revision.get( + resource_group_name=resource_group.name, + service_name="str", + portal_revision_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.portal_revision.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + portal_revision_id="str", + parameters={ + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "isCurrent": bool, + "name": "str", + "provisioningState": "str", + "status": "str", + "statusDetails": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.portal_revision.begin_update( + resource_group_name=resource_group.name, + service_name="str", + portal_revision_id="str", + if_match="str", + parameters={ + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "isCurrent": bool, + "name": "str", + "provisioningState": "str", + "status": "str", + "statusDetails": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations_async.py new file mode 100644 index 000000000000..a494c50c66bd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations_async.py @@ -0,0 +1,113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPortalRevisionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.portal_revision.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.portal_revision.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + portal_revision_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.portal_revision.get( + resource_group_name=resource_group.name, + service_name="str", + portal_revision_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.portal_revision.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + portal_revision_id="str", + parameters={ + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "isCurrent": bool, + "name": "str", + "provisioningState": "str", + "status": "str", + "statusDetails": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.portal_revision.begin_update( + resource_group_name=resource_group.name, + service_name="str", + portal_revision_id="str", + if_match="str", + parameters={ + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "isCurrent": bool, + "name": "str", + "provisioningState": "str", + "status": "str", + "statusDetails": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations.py new file mode 100644 index 000000000000..7420c6b7c76e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPortalSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.portal_settings.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations_async.py new file mode 100644 index 000000000000..24daceda1d72 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPortalSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = await self.client.portal_settings.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_private_endpoint_connection_operations.py new file mode 100644 index 000000000000..8cfd921c75c3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_private_endpoint_connection_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPrivateEndpointConnectionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.private_endpoint_connection.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_name(self, resource_group): + response = self.client.private_endpoint_connection.get_by_name( + resource_group_name=resource_group.name, + service_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.private_endpoint_connection.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection_request={ + "id": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + } + }, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.private_endpoint_connection.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_private_link_resources(self, resource_group): + response = self.client.private_endpoint_connection.list_private_link_resources( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_private_link_resource(self, resource_group): + response = self.client.private_endpoint_connection.get_private_link_resource( + resource_group_name=resource_group.name, + service_name="str", + private_link_sub_resource_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_private_endpoint_connection_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_private_endpoint_connection_operations_async.py new file mode 100644 index 000000000000..a9df484c1689 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_private_endpoint_connection_operations_async.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementPrivateEndpointConnectionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.private_endpoint_connection.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_name(self, resource_group): + response = await self.client.private_endpoint_connection.get_by_name( + resource_group_name=resource_group.name, + service_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connection.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection_request={ + "id": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + } + }, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connection.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + private_endpoint_connection_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_private_link_resources(self, resource_group): + response = await self.client.private_endpoint_connection.list_private_link_resources( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_private_link_resource(self, resource_group): + response = await self.client.private_endpoint_connection.get_private_link_resource( + resource_group_name=resource_group.name, + service_name="str", + private_link_sub_resource_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations.py new file mode 100644 index 000000000000..101ae71c1edf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductApiLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.product_api_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.product_api_link.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.product_api_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_link_id="str", + parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.product_api_link.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations_async.py new file mode 100644 index 000000000000..0291635f4124 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations_async.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductApiLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.product_api_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.product_api_link.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.product_api_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_link_id="str", + parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.product_api_link.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations.py new file mode 100644 index 000000000000..1bd3b55aa5ce --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductApiOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.product_api.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_entity_exists(self, resource_group): + response = self.client.product_api.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.product_api.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.product_api.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations_async.py new file mode 100644 index 000000000000..f04120d2b5b4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductApiOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.product_api.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_entity_exists(self, resource_group): + response = await self.client.product_api.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.product_api.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.product_api.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations.py new file mode 100644 index 000000000000..29a96fe6eb54 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductGroupLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.product_group_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.product_group_link.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.product_group_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_link_id="str", + parameters={"groupId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.product_group_link.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations_async.py new file mode 100644 index 000000000000..33fd24be8e3e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations_async.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductGroupLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.product_group_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.product_group_link.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.product_group_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_link_id="str", + parameters={"groupId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.product_group_link.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations.py new file mode 100644 index 000000000000..37d52428069b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductGroupOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.product_group.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_entity_exists(self, resource_group): + response = self.client.product_group.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.product_group.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.product_group.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations_async.py new file mode 100644 index 000000000000..418fab962402 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductGroupOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.product_group.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_entity_exists(self, resource_group): + response = await self.client.product_group.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.product_group.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.product_group.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_operations.py new file mode 100644 index 000000000000..bfc7dcd28758 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_operations.py @@ -0,0 +1,131 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.product.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.product.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.product.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.product.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + parameters={ + "approvalRequired": bool, + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.product.update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + if_match="str", + parameters={ + "approvalRequired": bool, + "description": "str", + "displayName": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.product.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_tags(self, resource_group): + response = self.client.product.list_by_tags( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_operations_async.py new file mode 100644 index 000000000000..21f3fa876f7c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_operations_async.py @@ -0,0 +1,132 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.product.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.product.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.product.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.product.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + parameters={ + "approvalRequired": bool, + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.product.update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + if_match="str", + parameters={ + "approvalRequired": bool, + "description": "str", + "displayName": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.product.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_tags(self, resource_group): + response = self.client.product.list_by_tags( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations.py new file mode 100644 index 000000000000..9773a291280e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.product_policy.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.product_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.product_policy.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.product_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.product_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations_async.py new file mode 100644 index 000000000000..f51808e734ab --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.product_policy.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.product_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.product_policy.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.product_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.product_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations.py new file mode 100644 index 000000000000..9475eda91fb2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductSubscriptionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.product_subscriptions.list( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations_async.py new file mode 100644 index 000000000000..c47067f09687 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductSubscriptionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.product_subscriptions.list( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wiki_operations.py new file mode 100644 index 000000000000..c3325fb9d8ea --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wiki_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductWikiOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.product_wiki.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.product_wiki.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.product_wiki.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + parameters={"documents": [{"documentationId": "str"}], "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.product_wiki.update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + if_match="str", + parameters={"documents": [{"documentationId": "str"}]}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.product_wiki.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wiki_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wiki_operations_async.py new file mode 100644 index 000000000000..8b336064e0bb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wiki_operations_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductWikiOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.product_wiki.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.product_wiki.get( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.product_wiki.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + parameters={"documents": [{"documentationId": "str"}], "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.product_wiki.update( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + if_match="str", + parameters={"documents": [{"documentationId": "str"}]}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.product_wiki.delete( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wikis_operations.py new file mode 100644 index 000000000000..816302f42dda --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wikis_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductWikisOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.product_wikis.list( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wikis_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wikis_operations_async.py new file mode 100644 index 000000000000..42f9d2cf89df --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_wikis_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementProductWikisOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.product_wikis.list( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_counter_keys_operations.py new file mode 100644 index 000000000000..583ef1bcc898 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_counter_keys_operations.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementQuotaByCounterKeysOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.quota_by_counter_keys.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + quota_counter_key="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.quota_by_counter_keys.update( + resource_group_name=resource_group.name, + service_name="str", + quota_counter_key="str", + parameters={"callsCount": 0, "kbTransferred": 0.0}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_counter_keys_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_counter_keys_operations_async.py new file mode 100644 index 000000000000..5ab871c12e89 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_counter_keys_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementQuotaByCounterKeysOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = await self.client.quota_by_counter_keys.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + quota_counter_key="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.quota_by_counter_keys.update( + resource_group_name=resource_group.name, + service_name="str", + quota_counter_key="str", + parameters={"callsCount": 0, "kbTransferred": 0.0}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_period_keys_operations.py new file mode 100644 index 000000000000..dda4764368d9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_period_keys_operations.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementQuotaByPeriodKeysOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.quota_by_period_keys.get( + resource_group_name=resource_group.name, + service_name="str", + quota_counter_key="str", + quota_period_key="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.quota_by_period_keys.update( + resource_group_name=resource_group.name, + service_name="str", + quota_counter_key="str", + quota_period_key="str", + parameters={"callsCount": 0, "kbTransferred": 0.0}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_period_keys_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_period_keys_operations_async.py new file mode 100644 index 000000000000..e8f12f84a040 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_quota_by_period_keys_operations_async.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementQuotaByPeriodKeysOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.quota_by_period_keys.get( + resource_group_name=resource_group.name, + service_name="str", + quota_counter_key="str", + quota_period_key="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.quota_by_period_keys.update( + resource_group_name=resource_group.name, + service_name="str", + quota_counter_key="str", + quota_period_key="str", + parameters={"callsCount": 0, "kbTransferred": 0.0}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_region_operations.py new file mode 100644 index 000000000000..f56588047957 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_region_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementRegionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.region.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_region_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_region_operations_async.py new file mode 100644 index 000000000000..b23e69dd7ffe --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_region_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementRegionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.region.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_reports_operations.py new file mode 100644 index 000000000000..02bd0e76bf1c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_reports_operations.py @@ -0,0 +1,124 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementReportsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.reports.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_user(self, resource_group): + response = self.client.reports.list_by_user( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_operation(self, resource_group): + response = self.client.reports.list_by_operation( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.reports.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_geo(self, resource_group): + response = self.client.reports.list_by_geo( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.reports.list_by_subscription( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_time(self, resource_group): + response = self.client.reports.list_by_time( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + interval="1 day, 0:00:00", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_request(self, resource_group): + response = self.client.reports.list_by_request( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_reports_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_reports_operations_async.py new file mode 100644 index 000000000000..efceb508827b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_reports_operations_async.py @@ -0,0 +1,125 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementReportsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.reports.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_user(self, resource_group): + response = self.client.reports.list_by_user( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_operation(self, resource_group): + response = self.client.reports.list_by_operation( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.reports.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_geo(self, resource_group): + response = self.client.reports.list_by_geo( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.reports.list_by_subscription( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_time(self, resource_group): + response = self.client.reports.list_by_time( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + interval="1 day, 0:00:00", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_request(self, resource_group): + response = self.client.reports.list_by_request( + resource_group_name=resource_group.name, + service_name="str", + filter="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_in_settings_operations.py new file mode 100644 index 000000000000..6a9c3e424b4a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_in_settings_operations.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementSignInSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.sign_in_settings.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.sign_in_settings.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.sign_in_settings.update( + resource_group_name=resource_group.name, + service_name="str", + if_match="str", + parameters={"enabled": bool, "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.sign_in_settings.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={"enabled": bool, "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_in_settings_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_in_settings_operations_async.py new file mode 100644 index 000000000000..7c1fd44f6036 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_in_settings_operations_async.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementSignInSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.sign_in_settings.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.sign_in_settings.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.sign_in_settings.update( + resource_group_name=resource_group.name, + service_name="str", + if_match="str", + parameters={"enabled": bool, "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.sign_in_settings.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={"enabled": bool, "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_up_settings_operations.py new file mode 100644 index 000000000000..78664a917df4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_up_settings_operations.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementSignUpSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.sign_up_settings.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.sign_up_settings.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.sign_up_settings.update( + resource_group_name=resource_group.name, + service_name="str", + if_match="str", + parameters={ + "enabled": bool, + "id": "str", + "name": "str", + "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.sign_up_settings.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "enabled": bool, + "id": "str", + "name": "str", + "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_up_settings_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_up_settings_operations_async.py new file mode 100644 index 000000000000..bf75354a15df --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_sign_up_settings_operations_async.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementSignUpSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.sign_up_settings.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.sign_up_settings.get( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.sign_up_settings.update( + resource_group_name=resource_group.name, + service_name="str", + if_match="str", + parameters={ + "enabled": bool, + "id": "str", + "name": "str", + "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.sign_up_settings.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + parameters={ + "enabled": bool, + "id": "str", + "name": "str", + "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_subscription_operations.py new file mode 100644 index 000000000000..59320d0d9d48 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_subscription_operations.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementSubscriptionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.subscription.list( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.subscription.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.subscription.get( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.subscription.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + parameters={ + "allowTracing": bool, + "displayName": "str", + "ownerId": "str", + "primaryKey": "str", + "scope": "str", + "secondaryKey": "str", + "state": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.subscription.update( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + if_match="str", + parameters={ + "allowTracing": bool, + "displayName": "str", + "expirationDate": "2020-02-20 00:00:00", + "ownerId": "str", + "primaryKey": "str", + "scope": "str", + "secondaryKey": "str", + "state": "str", + "stateComment": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.subscription.delete( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_primary_key(self, resource_group): + response = self.client.subscription.regenerate_primary_key( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_secondary_key(self, resource_group): + response = self.client.subscription.regenerate_secondary_key( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_secrets(self, resource_group): + response = self.client.subscription.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_subscription_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_subscription_operations_async.py new file mode 100644 index 000000000000..91f4edbc9a70 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_subscription_operations_async.py @@ -0,0 +1,158 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementSubscriptionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.subscription.list( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.subscription.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.subscription.get( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.subscription.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + parameters={ + "allowTracing": bool, + "displayName": "str", + "ownerId": "str", + "primaryKey": "str", + "scope": "str", + "secondaryKey": "str", + "state": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.subscription.update( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + if_match="str", + parameters={ + "allowTracing": bool, + "displayName": "str", + "expirationDate": "2020-02-20 00:00:00", + "ownerId": "str", + "primaryKey": "str", + "scope": "str", + "secondaryKey": "str", + "state": "str", + "stateComment": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.subscription.delete( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_primary_key(self, resource_group): + response = await self.client.subscription.regenerate_primary_key( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_secondary_key(self, resource_group): + response = await self.client.subscription.regenerate_secondary_key( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_secrets(self, resource_group): + response = await self.client.subscription.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations.py new file mode 100644 index 000000000000..88bee174b36e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagApiLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.tag_api_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.tag_api_link.get( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.tag_api_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_link_id="str", + parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.tag_api_link.delete( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations_async.py new file mode 100644 index 000000000000..fe777583731b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations_async.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagApiLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.tag_api_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.tag_api_link.get( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.tag_api_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_link_id="str", + parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.tag_api_link.delete( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations.py new file mode 100644 index 000000000000..4eca3e90d4f9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagOperationLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.tag_operation_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.tag_operation_link.get( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + operation_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.tag_operation_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + operation_link_id="str", + parameters={"id": "str", "name": "str", "operationId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.tag_operation_link.delete( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + operation_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations_async.py new file mode 100644 index 000000000000..93577eb35051 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations_async.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagOperationLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.tag_operation_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.tag_operation_link.get( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + operation_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.tag_operation_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + operation_link_id="str", + parameters={"id": "str", "name": "str", "operationId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.tag_operation_link.delete( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + operation_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations.py new file mode 100644 index 000000000000..e3ca977d218f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations.py @@ -0,0 +1,312 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_operation(self, resource_group): + response = self.client.tag.list_by_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_state_by_operation(self, resource_group): + response = self.client.tag.get_entity_state_by_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_operation(self, resource_group): + response = self.client.tag.get_by_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assign_to_operation(self, resource_group): + response = self.client.tag.assign_to_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_detach_from_operation(self, resource_group): + response = self.client.tag.detach_from_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.tag.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_state_by_api(self, resource_group): + response = self.client.tag.get_entity_state_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_api(self, resource_group): + response = self.client.tag.get_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assign_to_api(self, resource_group): + response = self.client.tag.assign_to_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_detach_from_api(self, resource_group): + response = self.client.tag.detach_from_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.tag.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_state_by_product(self, resource_group): + response = self.client.tag.get_entity_state_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_by_product(self, resource_group): + response = self.client.tag.get_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_assign_to_product(self, resource_group): + response = self.client.tag.assign_to_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_detach_from_product(self, resource_group): + response = self.client.tag.detach_from_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.tag.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_state(self, resource_group): + response = self.client.tag.get_entity_state( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.tag.get( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.tag.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + parameters={"displayName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.tag.update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + if_match="str", + parameters={"displayName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.tag.delete( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations_async.py new file mode 100644 index 000000000000..d9886078b965 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations_async.py @@ -0,0 +1,313 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_operation(self, resource_group): + response = self.client.tag.list_by_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_state_by_operation(self, resource_group): + response = await self.client.tag.get_entity_state_by_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_operation(self, resource_group): + response = await self.client.tag.get_by_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assign_to_operation(self, resource_group): + response = await self.client.tag.assign_to_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_detach_from_operation(self, resource_group): + response = await self.client.tag.detach_from_operation( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + operation_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.tag.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_state_by_api(self, resource_group): + response = await self.client.tag.get_entity_state_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_api(self, resource_group): + response = await self.client.tag.get_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assign_to_api(self, resource_group): + response = await self.client.tag.assign_to_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_detach_from_api(self, resource_group): + response = await self.client.tag.detach_from_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.tag.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_state_by_product(self, resource_group): + response = await self.client.tag.get_entity_state_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_by_product(self, resource_group): + response = await self.client.tag.get_by_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_assign_to_product(self, resource_group): + response = await self.client.tag.assign_to_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_detach_from_product(self, resource_group): + response = await self.client.tag.detach_from_product( + resource_group_name=resource_group.name, + service_name="str", + product_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.tag.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_state(self, resource_group): + response = await self.client.tag.get_entity_state( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.tag.get( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.tag.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + parameters={"displayName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.tag.update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + if_match="str", + parameters={"displayName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.tag.delete( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations.py new file mode 100644 index 000000000000..19ec80561d5d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagProductLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.tag_product_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.tag_product_link.get( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + product_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.tag_product_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + product_link_id="str", + parameters={"id": "str", "name": "str", "productId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.tag_product_link.delete( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + product_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations_async.py new file mode 100644 index 000000000000..41d43ddaf46d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations_async.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagProductLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.tag_product_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.tag_product_link.get( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + product_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.tag_product_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + product_link_id="str", + parameters={"id": "str", "name": "str", "productId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.tag_product_link.delete( + resource_group_name=resource_group.name, + service_name="str", + tag_id="str", + product_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations.py new file mode 100644 index 000000000000..677da619ff60 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagResourceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.tag_resource.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations_async.py new file mode 100644 index 000000000000..2fdc0b3f81b2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTagResourceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.tag_resource.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_git_operations.py new file mode 100644 index 000000000000..5fb935f4ab90 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_git_operations.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTenantAccessGitOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_primary_key(self, resource_group): + response = self.client.tenant_access_git.regenerate_primary_key( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_secondary_key(self, resource_group): + response = self.client.tenant_access_git.regenerate_secondary_key( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_git_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_git_operations_async.py new file mode 100644 index 000000000000..31060bb33f43 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_git_operations_async.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTenantAccessGitOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_primary_key(self, resource_group): + response = await self.client.tenant_access_git.regenerate_primary_key( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_secondary_key(self, resource_group): + response = await self.client.tenant_access_git.regenerate_secondary_key( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_operations.py new file mode 100644 index 000000000000..4a5f43561891 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_operations.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTenantAccessOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.tenant_access.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.tenant_access.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.tenant_access.get( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.tenant_access.create( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + if_match="str", + parameters={"enabled": bool, "primaryKey": "str", "principalId": "str", "secondaryKey": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.tenant_access.update( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + if_match="str", + parameters={"enabled": bool}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_primary_key(self, resource_group): + response = self.client.tenant_access.regenerate_primary_key( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_secondary_key(self, resource_group): + response = self.client.tenant_access.regenerate_secondary_key( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_secrets(self, resource_group): + response = self.client.tenant_access.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_operations_async.py new file mode 100644 index 000000000000..ba1464b9e02e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_access_operations_async.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTenantAccessOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.tenant_access.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.tenant_access.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.tenant_access.get( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.tenant_access.create( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + if_match="str", + parameters={"enabled": bool, "primaryKey": "str", "principalId": "str", "secondaryKey": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.tenant_access.update( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + if_match="str", + parameters={"enabled": bool}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_primary_key(self, resource_group): + response = await self.client.tenant_access.regenerate_primary_key( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_secondary_key(self, resource_group): + response = await self.client.tenant_access.regenerate_secondary_key( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_secrets(self, resource_group): + response = await self.client.tenant_access.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + access_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_configuration_operations.py new file mode 100644 index 000000000000..9d3778c1faa5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_configuration_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTenantConfigurationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_deploy(self, resource_group): + response = self.client.tenant_configuration.begin_deploy( + resource_group_name=resource_group.name, + service_name="str", + configuration_name="str", + parameters={"branch": "str", "force": bool}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_save(self, resource_group): + response = self.client.tenant_configuration.begin_save( + resource_group_name=resource_group.name, + service_name="str", + configuration_name="str", + parameters={"branch": "str", "force": bool}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_validate(self, resource_group): + response = self.client.tenant_configuration.begin_validate( + resource_group_name=resource_group.name, + service_name="str", + configuration_name="str", + parameters={"branch": "str", "force": bool}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_sync_state(self, resource_group): + response = self.client.tenant_configuration.get_sync_state( + resource_group_name=resource_group.name, + service_name="str", + configuration_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_configuration_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_configuration_operations_async.py new file mode 100644 index 000000000000..a5805cfc8a64 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_configuration_operations_async.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTenantConfigurationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_deploy(self, resource_group): + response = await ( + await self.client.tenant_configuration.begin_deploy( + resource_group_name=resource_group.name, + service_name="str", + configuration_name="str", + parameters={"branch": "str", "force": bool}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_save(self, resource_group): + response = await ( + await self.client.tenant_configuration.begin_save( + resource_group_name=resource_group.name, + service_name="str", + configuration_name="str", + parameters={"branch": "str", "force": bool}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_validate(self, resource_group): + response = await ( + await self.client.tenant_configuration.begin_validate( + resource_group_name=resource_group.name, + service_name="str", + configuration_name="str", + parameters={"branch": "str", "force": bool}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_sync_state(self, resource_group): + response = await self.client.tenant_configuration.get_sync_state( + resource_group_name=resource_group.name, + service_name="str", + configuration_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations.py new file mode 100644 index 000000000000..4a21f1392116 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTenantSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.tenant_settings.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.tenant_settings.get( + resource_group_name=resource_group.name, + service_name="str", + settings_type="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations_async.py new file mode 100644 index 000000000000..901a65ed26de --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementTenantSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.tenant_settings.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.tenant_settings.get( + resource_group_name=resource_group.name, + service_name="str", + settings_type="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations.py new file mode 100644 index 000000000000..d347aed491cd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserConfirmationPasswordOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_send(self, resource_group): + response = self.client.user_confirmation_password.send( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations_async.py new file mode 100644 index 000000000000..b64e29b87994 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserConfirmationPasswordOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_send(self, resource_group): + response = await self.client.user_confirmation_password.send( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_group_operations.py new file mode 100644 index 000000000000..9d41c661356e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_group_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserGroupOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.user_group.list( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_group_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_group_operations_async.py new file mode 100644 index 000000000000..dd0dd65de2cf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_group_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserGroupOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.user_group.list( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_identities_operations.py new file mode 100644 index 000000000000..5593825bc588 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_identities_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserIdentitiesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.user_identities.list( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_identities_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_identities_operations_async.py new file mode 100644 index 000000000000..d698baeab880 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_identities_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserIdentitiesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.user_identities.list( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_operations.py new file mode 100644 index 000000000000..434ba9eeedfe --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_operations.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.user.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.user.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.user.get( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.user.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + parameters={ + "appType": "str", + "confirmation": "str", + "email": "str", + "firstName": "str", + "identities": [{"id": "str", "provider": "str"}], + "lastName": "str", + "note": "str", + "password": "str", + "state": "active", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.user.update( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + if_match="str", + parameters={ + "email": "str", + "firstName": "str", + "identities": [{"id": "str", "provider": "str"}], + "lastName": "str", + "note": "str", + "password": "str", + "state": "active", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.user.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + if_match="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_generate_sso_url(self, resource_group): + response = self.client.user.generate_sso_url( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_shared_access_token(self, resource_group): + response = self.client.user.get_shared_access_token( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + parameters={"expiry": "2020-02-20 00:00:00", "keyType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_operations_async.py new file mode 100644 index 000000000000..dd60e4e54b37 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_operations_async.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.user.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.user.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.user.get( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.user.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + parameters={ + "appType": "str", + "confirmation": "str", + "email": "str", + "firstName": "str", + "identities": [{"id": "str", "provider": "str"}], + "lastName": "str", + "note": "str", + "password": "str", + "state": "active", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.user.update( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + if_match="str", + parameters={ + "email": "str", + "firstName": "str", + "identities": [{"id": "str", "provider": "str"}], + "lastName": "str", + "note": "str", + "password": "str", + "state": "active", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.user.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + if_match="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_generate_sso_url(self, resource_group): + response = await self.client.user.generate_sso_url( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_shared_access_token(self, resource_group): + response = await self.client.user.get_shared_access_token( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + parameters={"expiry": "2020-02-20 00:00:00", "keyType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations.py new file mode 100644 index 000000000000..aa07a2ca04f0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserSubscriptionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.user_subscription.list( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.user_subscription.get( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations_async.py new file mode 100644 index 000000000000..0669d35cbe44 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementUserSubscriptionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.user_subscription.list( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.user_subscription.get( + resource_group_name=resource_group.name, + service_name="str", + user_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations.py new file mode 100644 index 000000000000..8fd44665fa4d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations.py @@ -0,0 +1,208 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiDiagnosticOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_workspace(self, resource_group): + response = self.client.workspace_api_diagnostic.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_api_diagnostic.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api_diagnostic.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_api_diagnostic.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_api_diagnostic.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + if_match="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_api_diagnostic.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations_async.py new file mode 100644 index 000000000000..9f547e1b0b4d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations_async.py @@ -0,0 +1,209 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiDiagnosticOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_workspace(self, resource_group): + response = self.client.workspace_api_diagnostic.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_api_diagnostic.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api_diagnostic.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_api_diagnostic.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_api_diagnostic.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + if_match="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_api_diagnostic.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + diagnostic_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations.py new file mode 100644 index 000000000000..482e4f308e8e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiExportOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api_export.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + format="str", + export="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations_async.py new file mode 100644 index 000000000000..e5288b0d8cfe --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations_async.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiExportOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api_export.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + format="str", + export="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations.py new file mode 100644 index 000000000000..263b4c2fa814 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations.py @@ -0,0 +1,385 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiOperationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.workspace_api_operation.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_api_operation.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api_operation.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_api_operation.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "method": "str", + "name": "str", + "policies": "str", + "request": { + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "queryParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + }, + "responses": [ + { + "statusCode": 0, + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + } + ], + "templateParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "type": "str", + "urlTemplate": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_api_operation.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + if_match="str", + parameters={ + "description": "str", + "displayName": "str", + "method": "str", + "policies": "str", + "request": { + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "queryParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + }, + "responses": [ + { + "statusCode": 0, + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + } + ], + "templateParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "urlTemplate": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_api_operation.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations_async.py new file mode 100644 index 000000000000..419f93ef2b81 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations_async.py @@ -0,0 +1,386 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiOperationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.workspace_api_operation.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_api_operation.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api_operation.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_api_operation.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "method": "str", + "name": "str", + "policies": "str", + "request": { + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "queryParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + }, + "responses": [ + { + "statusCode": 0, + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + } + ], + "templateParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "type": "str", + "urlTemplate": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_api_operation.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + if_match="str", + parameters={ + "description": "str", + "displayName": "str", + "method": "str", + "policies": "str", + "request": { + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "queryParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + }, + "responses": [ + { + "statusCode": 0, + "description": "str", + "headers": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "representations": [ + { + "contentType": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "formParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": { + "description": "str", + "externalValue": "str", + "summary": "str", + "value": {}, + } + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "schemaId": "str", + "typeName": "str", + } + ], + } + ], + "templateParameters": [ + { + "name": "str", + "type": "str", + "defaultValue": "str", + "description": "str", + "examples": { + "str": {"description": "str", "externalValue": "str", "summary": "str", "value": {}} + }, + "required": bool, + "schemaId": "str", + "typeName": "str", + "values": ["str"], + } + ], + "urlTemplate": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_api_operation.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations.py new file mode 100644 index 000000000000..d8daf3fcd887 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiOperationPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_operation(self, resource_group): + response = self.client.workspace_api_operation_policy.list_by_operation( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_api_operation_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api_operation_policy.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_api_operation_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_api_operation_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations_async.py new file mode 100644 index 000000000000..1e614b82f6a8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiOperationPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_operation(self, resource_group): + response = self.client.workspace_api_operation_policy.list_by_operation( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_api_operation_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api_operation_policy.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_api_operation_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_api_operation_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + operation_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations.py new file mode 100644 index 000000000000..544ab59245ab --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations.py @@ -0,0 +1,171 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_api.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_api.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.workspace_api.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + parameters={ + "apiRevision": "str", + "apiRevisionDescription": "str", + "apiType": "str", + "apiVersion": "str", + "apiVersionDescription": "str", + "apiVersionSet": { + "description": "str", + "id": "str", + "name": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + "apiVersionSetId": "str", + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "str", "scope": "str"}, + "oAuth2AuthenticationSettings": [{"authorizationServerId": "str", "scope": "str"}], + "openid": {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}, + "openidAuthenticationSettings": [{"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}], + }, + "contact": {"email": "str", "name": "str", "url": "str"}, + "description": "str", + "displayName": "str", + "format": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "str"}, + "path": "str", + "protocols": ["str"], + "provisioningState": "str", + "serviceUrl": "str", + "sourceApiId": "str", + "subscriptionKeyParameterNames": {"header": "str", "query": "str"}, + "subscriptionRequired": bool, + "termsOfServiceUrl": "str", + "translateRequiredQueryParameters": "str", + "type": "str", + "value": "str", + "wsdlSelector": {"wsdlEndpointName": "str", "wsdlServiceName": "str"}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_api.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + if_match="str", + parameters={ + "apiRevision": "str", + "apiRevisionDescription": "str", + "apiVersion": "str", + "apiVersionDescription": "str", + "apiVersionSetId": "str", + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "str", "scope": "str"}, + "oAuth2AuthenticationSettings": [{"authorizationServerId": "str", "scope": "str"}], + "openid": {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}, + "openidAuthenticationSettings": [{"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}], + }, + "contact": {"email": "str", "name": "str", "url": "str"}, + "description": "str", + "displayName": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "str"}, + "path": "str", + "protocols": ["str"], + "serviceUrl": "str", + "subscriptionKeyParameterNames": {"header": "str", "query": "str"}, + "subscriptionRequired": bool, + "termsOfServiceUrl": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_api.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations_async.py new file mode 100644 index 000000000000..1080ce02f2e5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations_async.py @@ -0,0 +1,176 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_api.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_api.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_api.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + parameters={ + "apiRevision": "str", + "apiRevisionDescription": "str", + "apiType": "str", + "apiVersion": "str", + "apiVersionDescription": "str", + "apiVersionSet": { + "description": "str", + "id": "str", + "name": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + "apiVersionSetId": "str", + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "str", "scope": "str"}, + "oAuth2AuthenticationSettings": [{"authorizationServerId": "str", "scope": "str"}], + "openid": {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}, + "openidAuthenticationSettings": [ + {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"} + ], + }, + "contact": {"email": "str", "name": "str", "url": "str"}, + "description": "str", + "displayName": "str", + "format": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "str"}, + "path": "str", + "protocols": ["str"], + "provisioningState": "str", + "serviceUrl": "str", + "sourceApiId": "str", + "subscriptionKeyParameterNames": {"header": "str", "query": "str"}, + "subscriptionRequired": bool, + "termsOfServiceUrl": "str", + "translateRequiredQueryParameters": "str", + "type": "str", + "value": "str", + "wsdlSelector": {"wsdlEndpointName": "str", "wsdlServiceName": "str"}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_api.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + if_match="str", + parameters={ + "apiRevision": "str", + "apiRevisionDescription": "str", + "apiVersion": "str", + "apiVersionDescription": "str", + "apiVersionSetId": "str", + "authenticationSettings": { + "oAuth2": {"authorizationServerId": "str", "scope": "str"}, + "oAuth2AuthenticationSettings": [{"authorizationServerId": "str", "scope": "str"}], + "openid": {"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}, + "openidAuthenticationSettings": [{"bearerTokenSendingMethods": ["str"], "openidProviderId": "str"}], + }, + "contact": {"email": "str", "name": "str", "url": "str"}, + "description": "str", + "displayName": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "str"}, + "path": "str", + "protocols": ["str"], + "serviceUrl": "str", + "subscriptionKeyParameterNames": {"header": "str", "query": "str"}, + "subscriptionRequired": bool, + "termsOfServiceUrl": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_api.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations.py new file mode 100644 index 000000000000..9c471f621429 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.workspace_api_policy.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_api_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api_policy.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_api_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_api_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations_async.py new file mode 100644 index 000000000000..05c667087792 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations_async.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.workspace_api_policy.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_api_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api_policy.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_api_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_api_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations.py new file mode 100644 index 000000000000..865be18f7683 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiReleaseOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_api_release.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_api_release.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api_release.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_api_release.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + parameters={ + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "notes": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_api_release.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + if_match="str", + parameters={ + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "notes": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_api_release.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations_async.py new file mode 100644 index 000000000000..3a2cefef22b9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations_async.py @@ -0,0 +1,129 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiReleaseOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_api_release.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_api_release.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api_release.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_api_release.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + parameters={ + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "notes": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_api_release.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + if_match="str", + parameters={ + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "notes": "str", + "type": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_api_release.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + release_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations.py new file mode 100644 index 000000000000..db198a486d89 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiRevisionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_api_revision.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations_async.py new file mode 100644 index 000000000000..73bc998a92cd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiRevisionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_api_revision.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations.py new file mode 100644 index 000000000000..9ebd041f553e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiSchemaOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.workspace_api_schema.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_api_schema.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api_schema.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.workspace_api_schema.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + schema_id="str", + parameters={ + "components": {}, + "contentType": "str", + "definitions": {}, + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_api_schema.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + schema_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations_async.py new file mode 100644 index 000000000000..ba93356c60dc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations_async.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiSchemaOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.workspace_api_schema.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_api_schema.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api_schema.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_api_schema.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + schema_id="str", + parameters={ + "components": {}, + "contentType": "str", + "definitions": {}, + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_api_schema.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_id="str", + schema_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations.py new file mode 100644 index 000000000000..36486076c543 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations.py @@ -0,0 +1,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiVersionSetOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_api_version_set.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_api_version_set.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_api_version_set.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_api_version_set.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "type": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_api_version_set.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + if_match="str", + parameters={ + "description": "str", + "displayName": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_api_version_set.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations_async.py new file mode 100644 index 000000000000..aec2ed9e81e6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations_async.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceApiVersionSetOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_api_version_set.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_api_version_set.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_api_version_set.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_api_version_set.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + parameters={ + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "type": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_api_version_set.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + if_match="str", + parameters={ + "description": "str", + "displayName": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_api_version_set.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + version_set_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations.py new file mode 100644 index 000000000000..9f98cdcd8950 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations.py @@ -0,0 +1,194 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceBackendOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_workspace(self, resource_group): + response = self.client.workspace_backend.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_backend.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_backend.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_backend.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + parameters={ + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "name": "str", + "tripDuration": "1 day, 0:00:00", + } + ] + }, + "credentials": { + "authorization": {"parameter": "str", "scheme": "str"}, + "certificate": ["str"], + "certificateIds": ["str"], + "header": {"str": ["str"]}, + "query": {"str": ["str"]}, + }, + "description": "str", + "id": "str", + "name": "str", + "pool": {"services": [{"id": "str", "priority": 0, "weight": 0}]}, + "properties": { + "serviceFabricCluster": { + "managementEndpoints": ["str"], + "clientCertificateId": "str", + "clientCertificatethumbprint": "str", + "maxPartitionResolutionRetries": 0, + "serverCertificateThumbprints": ["str"], + "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], + } + }, + "protocol": "str", + "proxy": {"url": "str", "password": "str", "username": "str"}, + "resourceId": "str", + "title": "str", + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "type": "str", + "url": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_backend.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + if_match="str", + parameters={ + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "name": "str", + "tripDuration": "1 day, 0:00:00", + } + ] + }, + "credentials": { + "authorization": {"parameter": "str", "scheme": "str"}, + "certificate": ["str"], + "certificateIds": ["str"], + "header": {"str": ["str"]}, + "query": {"str": ["str"]}, + }, + "description": "str", + "pool": {"services": [{"id": "str", "priority": 0, "weight": 0}]}, + "properties": { + "serviceFabricCluster": { + "managementEndpoints": ["str"], + "clientCertificateId": "str", + "clientCertificatethumbprint": "str", + "maxPartitionResolutionRetries": 0, + "serverCertificateThumbprints": ["str"], + "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], + } + }, + "protocol": "str", + "proxy": {"url": "str", "password": "str", "username": "str"}, + "resourceId": "str", + "title": "str", + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "type": "str", + "url": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_backend.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations_async.py new file mode 100644 index 000000000000..5acc8aca4879 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations_async.py @@ -0,0 +1,195 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceBackendOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_workspace(self, resource_group): + response = self.client.workspace_backend.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_backend.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_backend.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_backend.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + parameters={ + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "name": "str", + "tripDuration": "1 day, 0:00:00", + } + ] + }, + "credentials": { + "authorization": {"parameter": "str", "scheme": "str"}, + "certificate": ["str"], + "certificateIds": ["str"], + "header": {"str": ["str"]}, + "query": {"str": ["str"]}, + }, + "description": "str", + "id": "str", + "name": "str", + "pool": {"services": [{"id": "str", "priority": 0, "weight": 0}]}, + "properties": { + "serviceFabricCluster": { + "managementEndpoints": ["str"], + "clientCertificateId": "str", + "clientCertificatethumbprint": "str", + "maxPartitionResolutionRetries": 0, + "serverCertificateThumbprints": ["str"], + "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], + } + }, + "protocol": "str", + "proxy": {"url": "str", "password": "str", "username": "str"}, + "resourceId": "str", + "title": "str", + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "type": "str", + "url": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_backend.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + if_match="str", + parameters={ + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "name": "str", + "tripDuration": "1 day, 0:00:00", + } + ] + }, + "credentials": { + "authorization": {"parameter": "str", "scheme": "str"}, + "certificate": ["str"], + "certificateIds": ["str"], + "header": {"str": ["str"]}, + "query": {"str": ["str"]}, + }, + "description": "str", + "pool": {"services": [{"id": "str", "priority": 0, "weight": 0}]}, + "properties": { + "serviceFabricCluster": { + "managementEndpoints": ["str"], + "clientCertificateId": "str", + "clientCertificatethumbprint": "str", + "maxPartitionResolutionRetries": 0, + "serverCertificateThumbprints": ["str"], + "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], + } + }, + "protocol": "str", + "proxy": {"url": "str", "password": "str", "username": "str"}, + "resourceId": "str", + "title": "str", + "tls": {"validateCertificateChain": True, "validateCertificateName": True}, + "type": "str", + "url": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_backend.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + backend_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations.py new file mode 100644 index 000000000000..eb3937472b05 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceCertificateOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_workspace(self, resource_group): + response = self.client.workspace_certificate.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_certificate.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_certificate.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_certificate.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + parameters={ + "data": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "password": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_certificate.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_refresh_secret(self, resource_group): + response = self.client.workspace_certificate.refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations_async.py new file mode 100644 index 000000000000..7184b9762c4e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations_async.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceCertificateOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_workspace(self, resource_group): + response = self.client.workspace_certificate.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_certificate.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_certificate.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_certificate.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + parameters={ + "data": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "password": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_certificate.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_refresh_secret(self, resource_group): + response = await self.client.workspace_certificate.refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + certificate_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations.py new file mode 100644 index 000000000000..56afa997f495 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations.py @@ -0,0 +1,202 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceDiagnosticOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_workspace(self, resource_group): + response = self.client.workspace_diagnostic.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_diagnostic.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_diagnostic.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_diagnostic.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_diagnostic.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + if_match="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_diagnostic.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations_async.py new file mode 100644 index 000000000000..673095ca8f63 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations_async.py @@ -0,0 +1,203 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceDiagnosticOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_workspace(self, resource_group): + response = self.client.workspace_diagnostic.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_diagnostic.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_diagnostic.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_diagnostic.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_diagnostic.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + if_match="str", + parameters={ + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], + }, + }, + "httpCorrelationProtocol": "str", + "id": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "name": "str", + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "type": "str", + "verbosity": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_diagnostic.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + diagnostic_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations.py new file mode 100644 index 000000000000..4fb9a6feb750 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceGlobalSchemaOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_global_schema.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_global_schema.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_global_schema.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.workspace_global_schema.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + schema_id="str", + parameters={ + "description": "str", + "document": {}, + "id": "str", + "name": "str", + "provisioningState": "str", + "schemaType": "str", + "type": "str", + "value": {}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_global_schema.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + schema_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations_async.py new file mode 100644 index 000000000000..158a2cb4524a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations_async.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceGlobalSchemaOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_global_schema.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_global_schema.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_global_schema.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + schema_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_global_schema.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + schema_id="str", + parameters={ + "description": "str", + "document": {}, + "id": "str", + "name": "str", + "provisioningState": "str", + "schemaType": "str", + "type": "str", + "value": {}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_global_schema.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + schema_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations.py new file mode 100644 index 000000000000..32be76d5e177 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceGroupOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_group.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_group.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_group.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_group.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_group.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + if_match="str", + parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_group.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations_async.py new file mode 100644 index 000000000000..7a1c4fcdd569 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations_async.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceGroupOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_group.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_group.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_group.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_group.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_group.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + if_match="str", + parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_group.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations.py new file mode 100644 index 000000000000..0d7fdd9abfde --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceGroupUserOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.workspace_group_user.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_entity_exists(self, resource_group): + response = self.client.workspace_group_user.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.workspace_group_user.create( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_group_user.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations_async.py new file mode 100644 index 000000000000..38215441e796 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations_async.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceGroupUserOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.workspace_group_user.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_entity_exists(self, resource_group): + response = await self.client.workspace_group_user.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.workspace_group_user.create( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_group_user.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + group_id="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations.py new file mode 100644 index 000000000000..09ebd8dc070d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceLoggerOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_workspace(self, resource_group): + response = self.client.workspace_logger.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_logger.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_logger.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_logger.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + parameters={ + "credentials": {"str": "str"}, + "description": "str", + "id": "str", + "isBuffered": bool, + "loggerType": "str", + "name": "str", + "resourceId": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_logger.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + if_match="str", + parameters={"credentials": {"str": "str"}, "description": "str", "isBuffered": bool, "loggerType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_logger.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations_async.py new file mode 100644 index 000000000000..640bb470761d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations_async.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceLoggerOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_workspace(self, resource_group): + response = self.client.workspace_logger.list_by_workspace( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_logger.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_logger.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_logger.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + parameters={ + "credentials": {"str": "str"}, + "description": "str", + "id": "str", + "isBuffered": bool, + "loggerType": "str", + "name": "str", + "resourceId": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_logger.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + if_match="str", + parameters={"credentials": {"str": "str"}, "description": "str", "isBuffered": bool, "loggerType": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_logger.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + logger_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations.py new file mode 100644 index 000000000000..788707d8fa6c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations.py @@ -0,0 +1,149 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceNamedValueOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_named_value.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_named_value.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_named_value.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.workspace_named_value.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + parameters={ + "displayName": "str", + "id": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "name": "str", + "secret": bool, + "tags": ["str"], + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.workspace_named_value.begin_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + if_match="str", + parameters={ + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_named_value.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_value(self, resource_group): + response = self.client.workspace_named_value.list_value( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_refresh_secret(self, resource_group): + response = self.client.workspace_named_value.begin_refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations_async.py new file mode 100644 index 000000000000..cb998e86f9d7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations_async.py @@ -0,0 +1,156 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceNamedValueOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_named_value.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_named_value.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_named_value.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_named_value.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + parameters={ + "displayName": "str", + "id": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "name": "str", + "secret": bool, + "tags": ["str"], + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.workspace_named_value.begin_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + if_match="str", + parameters={ + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_named_value.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_value(self, resource_group): + response = await self.client.workspace_named_value.list_value( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_refresh_secret(self, resource_group): + response = await ( + await self.client.workspace_named_value.begin_refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + named_value_id="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations.py new file mode 100644 index 000000000000..dc8012a68b3c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceNotificationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_notification.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_notification.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_notification.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations_async.py new file mode 100644 index 000000000000..d39e4dedc328 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations_async.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceNotificationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_notification.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_notification.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_notification.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations.py new file mode 100644 index 000000000000..0f0f435151b5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceNotificationRecipientEmailOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_notification(self, resource_group): + response = self.client.workspace_notification_recipient_email.list_by_notification( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_entity_exists(self, resource_group): + response = self.client.workspace_notification_recipient_email.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_notification_recipient_email.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_notification_recipient_email.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations_async.py new file mode 100644 index 000000000000..902db63e141d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations_async.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceNotificationRecipientEmailOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_notification(self, resource_group): + response = await self.client.workspace_notification_recipient_email.list_by_notification( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_entity_exists(self, resource_group): + response = await self.client.workspace_notification_recipient_email.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_notification_recipient_email.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_notification_recipient_email.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + email="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_user_operations.py new file mode 100644 index 000000000000..7c7af9682ac7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_user_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceNotificationRecipientUserOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_notification(self, resource_group): + response = self.client.workspace_notification_recipient_user.list_by_notification( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_entity_exists(self, resource_group): + response = self.client.workspace_notification_recipient_user.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_notification_recipient_user.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_notification_recipient_user.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_user_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_user_operations_async.py new file mode 100644 index 000000000000..f4c1456d73c3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_user_operations_async.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceNotificationRecipientUserOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_notification(self, resource_group): + response = await self.client.workspace_notification_recipient_user.list_by_notification( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_entity_exists(self, resource_group): + response = await self.client.workspace_notification_recipient_user.check_entity_exists( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_notification_recipient_user.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_notification_recipient_user.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + notification_name="str", + user_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations.py new file mode 100644 index 000000000000..ca3fc66b5034 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + parameters={"description": "str", "displayName": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + if_match="str", + parameters={"description": "str", "displayName": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations_async.py new file mode 100644 index 000000000000..0eb144aadf81 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + parameters={"description": "str", "displayName": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + if_match="str", + parameters={"description": "str", "displayName": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations.py new file mode 100644 index 000000000000..b64e57e836b4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspacePolicyFragmentOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_policy_fragment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_policy_fragment.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_policy_fragment.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.workspace_policy_fragment.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + parameters={ + "description": "str", + "format": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_policy_fragment.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_references(self, resource_group): + response = self.client.workspace_policy_fragment.list_references( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations_async.py new file mode 100644 index 000000000000..327ba3d0eae4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations_async.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspacePolicyFragmentOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_policy_fragment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_policy_fragment.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_policy_fragment.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_policy_fragment.begin_create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + parameters={ + "description": "str", + "format": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + "value": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_policy_fragment.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_references(self, resource_group): + response = await self.client.workspace_policy_fragment.list_references( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations.py new file mode 100644 index 000000000000..e03680b9fac9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspacePolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_api(self, resource_group): + response = self.client.workspace_policy.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_policy.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations_async.py new file mode 100644 index 000000000000..9df51f33ac01 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspacePolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_api(self, resource_group): + response = self.client.workspace_policy.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_policy.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations.py new file mode 100644 index 000000000000..00efa8c07c64 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceProductApiLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.workspace_product_api_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_product_api_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_product_api_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_link_id="str", + parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_product_api_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations_async.py new file mode 100644 index 000000000000..fb6f246cfd93 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations_async.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceProductApiLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.workspace_product_api_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_product_api_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_product_api_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_link_id="str", + parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_product_api_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations.py new file mode 100644 index 000000000000..a29d3836f2f0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceProductGroupLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.workspace_product_group_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_product_group_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + group_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_product_group_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + group_link_id="str", + parameters={"groupId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_product_group_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + group_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations_async.py new file mode 100644 index 000000000000..e08916976134 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations_async.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceProductGroupLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.workspace_product_group_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_product_group_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + group_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_product_group_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + group_link_id="str", + parameters={"groupId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_product_group_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + group_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations.py new file mode 100644 index 000000000000..2dfde5a92b0c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations.py @@ -0,0 +1,125 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceProductOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_product.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_product.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_product.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_product.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + parameters={ + "approvalRequired": bool, + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_product.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + if_match="str", + parameters={ + "approvalRequired": bool, + "description": "str", + "displayName": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_product.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations_async.py new file mode 100644 index 000000000000..3b40f42d5699 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations_async.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceProductOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_product.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_product.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_product.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_product.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + parameters={ + "approvalRequired": bool, + "description": "str", + "displayName": "str", + "id": "str", + "name": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + "type": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_product.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + if_match="str", + parameters={ + "approvalRequired": bool, + "description": "str", + "displayName": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_product.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations.py new file mode 100644 index 000000000000..044eb0ad3488 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceProductPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.workspace_product_policy.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_product_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_product_policy.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_product_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_product_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations_async.py new file mode 100644 index 000000000000..a4174e097841 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations_async.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceProductPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = await self.client.workspace_product_policy.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_product_policy.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_product_policy.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + policy_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_product_policy.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + policy_id="str", + parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_product_policy.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + product_id="str", + policy_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_subscription_operations.py new file mode 100644 index 000000000000..e8dacbab719a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_subscription_operations.py @@ -0,0 +1,166 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceSubscriptionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.workspace_subscription.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_tag(self, resource_group): + response = self.client.workspace_subscription.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_subscription.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_subscription.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + parameters={ + "allowTracing": bool, + "displayName": "str", + "ownerId": "str", + "primaryKey": "str", + "scope": "str", + "secondaryKey": "str", + "state": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_subscription.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + if_match="str", + parameters={ + "allowTracing": bool, + "displayName": "str", + "expirationDate": "2020-02-20 00:00:00", + "ownerId": "str", + "primaryKey": "str", + "scope": "str", + "secondaryKey": "str", + "state": "str", + "stateComment": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_subscription.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_primary_key(self, resource_group): + response = self.client.workspace_subscription.regenerate_primary_key( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_secondary_key(self, resource_group): + response = self.client.workspace_subscription.regenerate_secondary_key( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_secrets(self, resource_group): + response = self.client.workspace_subscription.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_subscription_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_subscription_operations_async.py new file mode 100644 index 000000000000..29b95e58c8ca --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_subscription_operations_async.py @@ -0,0 +1,167 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceSubscriptionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.workspace_subscription.list( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_tag(self, resource_group): + response = await self.client.workspace_subscription.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_subscription.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_subscription.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + parameters={ + "allowTracing": bool, + "displayName": "str", + "ownerId": "str", + "primaryKey": "str", + "scope": "str", + "secondaryKey": "str", + "state": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_subscription.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + if_match="str", + parameters={ + "allowTracing": bool, + "displayName": "str", + "expirationDate": "2020-02-20 00:00:00", + "ownerId": "str", + "primaryKey": "str", + "scope": "str", + "secondaryKey": "str", + "state": "str", + "stateComment": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_subscription.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_primary_key(self, resource_group): + response = await self.client.workspace_subscription.regenerate_primary_key( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_secondary_key(self, resource_group): + response = await self.client.workspace_subscription.regenerate_secondary_key( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_secrets(self, resource_group): + response = await self.client.workspace_subscription.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + sid="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations.py new file mode 100644 index 000000000000..f70f843ce3d2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceTagApiLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.workspace_tag_api_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_tag_api_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_tag_api_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_link_id="str", + parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_tag_api_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations_async.py new file mode 100644 index 000000000000..1462edf4bbc8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations_async.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceTagApiLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.workspace_tag_api_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_tag_api_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_tag_api_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_link_id="str", + parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_tag_api_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations.py new file mode 100644 index 000000000000..70338ae9b1ed --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceTagOperationLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.workspace_tag_operation_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_tag_operation_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + operation_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_tag_operation_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + operation_link_id="str", + parameters={"id": "str", "name": "str", "operationId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_tag_operation_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + operation_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations_async.py new file mode 100644 index 000000000000..1f81498033e4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations_async.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceTagOperationLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.workspace_tag_operation_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_tag_operation_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + operation_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_tag_operation_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + operation_link_id="str", + parameters={"id": "str", "name": "str", "operationId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_tag_operation_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + operation_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations.py new file mode 100644 index 000000000000..bb4d3bf7f583 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceTagOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_service(self, resource_group): + response = self.client.workspace_tag.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_entity_state(self, resource_group): + response = self.client.workspace_tag.get_entity_state( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_tag.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_tag.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + parameters={"displayName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.workspace_tag.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + if_match="str", + parameters={"displayName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_tag.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations_async.py new file mode 100644 index 000000000000..3d7601f44433 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations_async.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceTagOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_service(self, resource_group): + response = self.client.workspace_tag.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_entity_state(self, resource_group): + response = await self.client.workspace_tag.get_entity_state( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_tag.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_tag.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + parameters={"displayName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.workspace_tag.update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + if_match="str", + parameters={"displayName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_tag.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + if_match="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations.py new file mode 100644 index 000000000000..7dfacf1940cc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceTagProductLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_product(self, resource_group): + response = self.client.workspace_tag_product_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workspace_tag_product_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + product_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workspace_tag_product_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + product_link_id="str", + parameters={"id": "str", "name": "str", "productId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workspace_tag_product_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + product_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations_async.py new file mode 100644 index 000000000000..e8c6ec8bc995 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations_async.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.apimanagement.aio import ApiManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestApiManagementWorkspaceTagProductLinkOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_product(self, resource_group): + response = self.client.workspace_tag_product_link.list_by_product( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workspace_tag_product_link.get( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + product_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workspace_tag_product_link.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + product_link_id="str", + parameters={"id": "str", "name": "str", "productId": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workspace_tag_product_link.delete( + resource_group_name=resource_group.name, + service_name="str", + workspace_id="str", + tag_id="str", + product_link_id="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/setup.py b/sdk/apimanagement/azure-mgmt-apimanagement/setup.py index ba273ae4e388..6e06a94738de 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/setup.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/setup.py @@ -75,6 +75,7 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", "azure-mgmt-core>=1.3.2", ],